From e8237e6ae04e13c9758831a4d0121e38af0765e5 Mon Sep 17 00:00:00 2001 From: Shalini Chellathurai Saroja Date: Wed, 18 Jun 2025 08:56:45 +0200 Subject: [PATCH] cpictl: provide error for invalid options cpictl tool supports options which start with - or -- alone. Getopt command verifies options which start with - or -- alone. When an option that does not start with - or -- is provided, the tool commits the changes and does not report error as shown below. $ ./cpictl abc Inside cpi_commit function Report error and do not commit for invalid options. Signed-off-by: Shalini Chellathurai Saroja Reviewed-by: Peter Oberparleiter Signed-off-by: Steffen Eiden --- scripts/cpictl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/cpictl b/scripts/cpictl index 475a80f4..16cadde8 100755 --- a/scripts/cpictl +++ b/scripts/cpictl @@ -39,6 +39,7 @@ readonly EXIT_SUCCESS=0 readonly EXIT_FAILURE=1 readonly EXIT_ARG_TOO_LONG=3 readonly EXIT_INVALID_CHARS=4 +readonly EXIT_INVALID_ARGS=5 # Distro-IDs as supported by SE/HMC firmware readonly DISTRO_GENERIC=0 @@ -490,6 +491,11 @@ while [ -n $1 ]; do esac done +# Unparsed options are not supported +if [ $# -ne 0 ]; then + fail_with "$PRG: Invalid command-line option: $*" $EXIT_INVALID_ARGS +fi + # Print settings for --dry-run or commit them to sysfs otherwise if [ $DRYRUN -eq 1 ]; then