diff options
author | Aaron Ball <nullspoon@oper.io> | 2018-06-09 12:19:54 -0600 |
---|---|---|
committer | Aaron Ball <nullspoon@oper.io> | 2018-06-09 12:19:54 -0600 |
commit | 394d389fab7bd164278410e796f41cff1aaa2724 (patch) | |
tree | f47408d5069e0c9a66d3e59c1c1b44147d3ff763 | |
parent | 60a06067a7683d41653fe83ec5cbf6e74758fd81 (diff) | |
download | andbackup-394d389fab7bd164278410e796f41cff1aaa2724.tar.gz andbackup-394d389fab7bd164278410e796f41cff1aaa2724.tar.xz |
Moved help command check above root check
Previously, we checked for root (uid == 0) first, which meant non-root
users couldn't print the help text.
This moves the check for argument 1 == help out of the normal command
check list and above the root check, and adds an early return to prevent
further execution when the helptext is requested..
-rwxr-xr-x | andbackup.sh | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/andbackup.sh b/andbackup.sh index e8bbae8..c48a86f 100755 --- a/andbackup.sh +++ b/andbackup.sh @@ -315,6 +315,11 @@ main() { local cmd=${1:-} shift + if [ "${cmd}" = 'help' ]; then + usage + return 0 + fi + # Ensure root is running this script if [ $(id -u) -gt 0 ]; then lerror "Script must be run as root (uid 0)." @@ -333,8 +338,6 @@ main() { list_restore_apps ${@} elif [ "${cmd}" = 'ls' ] || [ "${cmd}" = 'list' ]; then list_apps - elif [ "${cmd}" = 'help' ]; then - usage else lerror "Unknown command '${cmd}'" usage |