From 59937aa5f448e26552eb894d57f3dbaf8a834cdb Mon Sep 17 00:00:00 2001 From: Newbyte Date: Sun, 15 Mar 2020 09:16:53 +0100 Subject: [PATCH 1/2] Show usage help when no arguments were passed --- build.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 6fd88fa..87389b6 100755 --- a/build.sh +++ b/build.sh @@ -177,6 +177,15 @@ uninstall() { rm -fv "/usr/bin/mangohud.x86" } +usage() { + if test -z $1; then + echo "Unrecognized command argument: $a" + else + echo "$0 requires at least one argument" + fi + echo 'Accepted arguments: "pull", "configure", "build", "package", "install", "clean", "uninstall".' +} + for a in $@; do case $a in "") build;; @@ -189,7 +198,11 @@ for a in $@; do "uninstall") uninstall;; "release") release;; *) - echo "Unrecognized command argument: $a" - echo 'Accepted arguments: "pull", "configure", "build", "package", "install", "clean", "uninstall".' + usage esac done + +if test -z $@; then + usage no-args +fi + From d0051c706366a4f9322c288fbe66433de480d57e Mon Sep 17 00:00:00 2001 From: Newbyte Date: Sun, 15 Mar 2020 09:27:19 +0100 Subject: [PATCH 2/2] Don't say "at least one argument" and fix issue with multiple arguments --- build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 87389b6..63f605f 100755 --- a/build.sh +++ b/build.sh @@ -181,7 +181,7 @@ usage() { if test -z $1; then echo "Unrecognized command argument: $a" else - echo "$0 requires at least one argument" + echo "$0 requires one argument" fi echo 'Accepted arguments: "pull", "configure", "build", "package", "install", "clean", "uninstall".' } @@ -202,7 +202,7 @@ for a in $@; do esac done -if test -z $@; then +if [[ -z $@ ]]; then usage no-args fi