Skip to content

Commit

Permalink
kas-container: Handle missing extra argument in subcommands gracefully
Browse files Browse the repository at this point in the history
When specifying a subcommand option that takes an extra argument without
that, kas-container currently just terminates without any error. That is
because "shift 2" just bails out dues to "set -e". Handle this case by
shifting the option first and then the extra argument. When the latter
fails, we simply make the subcommand dump its own help.

Signed-off-by: Jan Kiszka <[email protected]>
  • Loading branch information
jan-kiszka committed May 1, 2024
1 parent cf64260 commit 5d1ab6e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions kas-container
Original file line number Diff line number Diff line change
Expand Up @@ -330,18 +330,21 @@ while [ $# -gt 0 ] && [ $KAS_EXTRA_BITBAKE_ARGS -eq 0 ]; do
case "$1" in
--skip|--target|--task)
KAS_OPTIONS="${KAS_OPTIONS} $1 $2"
shift 2
shift 1
shift 1 || KAS_OPTIONS="--help"
;;
-c|--cmd|--command)
KAS_BITBAKE_C_OPTION_ARGS="$2"
shift 2
shift 1
shift 1 || KAS_OPTIONS="--help"
;;
-E|--preserve-env)
fatal_error "$1 is not supported with ${KAS_CONTAINER_SELF_NAME}"
;;
--provenance)
KAS_OPTIONS="${KAS_OPTIONS} $1 $2"
shift 2
shift 1
shift 1 || KAS_OPTIONS="--help"
;;
--)
KAS_EXTRA_BITBAKE_ARGS=$#
Expand Down

0 comments on commit 5d1ab6e

Please sign in to comment.