summaryrefslogtreecommitdiff
path: root/frontend/lb
diff options
context:
space:
mode:
authorRaphaël Hertzog <hertzog@debian.org>2020-04-24 16:00:05 +0200
committerRaphaël Hertzog <hertzog@debian.org>2020-04-24 16:24:01 +0200
commit55d9b213cfaa55f6be0ce9d803e3603dfbf87dd7 (patch)
tree5b5af2e4e3ccd1141792a3a8d11f2bb23c647900 /frontend/lb
parent104fa2039990f17e02dd9d2dbfc801763987b532 (diff)
downloadvyos-live-build-55d9b213cfaa55f6be0ce9d803e3603dfbf87dd7.tar.gz
vyos-live-build-55d9b213cfaa55f6be0ce9d803e3603dfbf87dd7.zip
Improve handling of options allowed for "lb" before the sub-command
Diffstat (limited to 'frontend/lb')
-rwxr-xr-xfrontend/lb37
1 files changed, 19 insertions, 18 deletions
diff --git a/frontend/lb b/frontend/lb
index 298b4255b..5dfa4cf53 100755
--- a/frontend/lb
+++ b/frontend/lb
@@ -19,25 +19,26 @@ DESCRIPTION="Utility to build live systems"
HELP=""
USAGE="lb {clean|config|build}"
-case "${1}" in
- -h|--help)
- if [ $(which man) ]; then
- man lb
- else
- Usage
- fi
- exit 0
- ;;
-
- ""|-u|--usage)
- Usage
- ;;
+# This bits of code relies on the fact that we only accept
+# options without values before the real command.
+GLOBAL_ARGS=""
+while true; do
+ case $1 in
+ -*)
+ GLOBAL_ARGS="${GLOBAL_ARGS:+$GLOBAL_ARGS }$1"
+ shift
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+Arguments $GLOBAL_ARGS
- -v|--version)
- echo "${VERSION}"
- exit 0
- ;;
-esac
+if [ $# = 0 ]; then
+ Echo_error "Missing sub-command"
+ Usage --fail
+fi
COMMAND="${1}"
shift