obmcutil: fix optional param regression
When adding support for "showlog", it regressed the support for the
optional parameters. That new option required all of the command line
parameters be passed on to handle_cmd().
handle_cmd() does not handle optional parameters though. Add some logic
to shift the optional parameters out before calling handle_cmd().
Tested:
Verified -v and -w/--wait now work as expected
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I81a66bdf32cab5f13f6acf0cabd5dca267029353
diff --git a/obmcutil b/obmcutil
index 788a55f..b9c5b18 100755
--- a/obmcutil
+++ b/obmcutil
@@ -72,7 +72,7 @@
echo "obmcutil deletelogs Delete all phosphor-logging entries from"
echo " system"
echo ""
- echo "optional arguments:"
+ echo "optional arguments (must precede the positional options above):"
echo " -h, --help show this help message and exit"
echo " -w, --wait block until state transition succeeds or fails"
echo " -v, --verbose print the journal to stdout if --wait is supplied"
@@ -436,10 +436,12 @@
esac
}
+shiftcnt=0
for arg in "$@"; do
case $arg in
-w|--wait)
G_WAIT=30
+ shiftcnt=$((shiftcnt+1))
continue
;;
-h|--help)
@@ -447,12 +449,15 @@
;;
-v|--verbose)
G_VERBOSE=y
+ shiftcnt=$((shiftcnt+1))
;;
-*)
print_usage_err "Unknown option: $arg"
;;
*)
G_ORIG_CMD=$arg
+ # shift out the optional parameters
+ shift $shiftcnt
# pass all arguments to handle_cmd in case command takes additional
# parameters
handle_cmd "$@"