summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@oper.io>2018-06-10 15:10:51 -0600
committerAaron Ball <nullspoon@oper.io>2018-06-10 15:10:51 -0600
commitd4710cc932956659ea76421d2d80936cd14ad510 (patch)
tree805893b137c55f948dcc8c5c8d7c5a138c28cef2
parenta83ee1cb8aa58ae9d9cf667329b8f807534a2631 (diff)
downloadandbackup-d4710cc932956659ea76421d2d80936cd14ad510.tar.gz
andbackup-d4710cc932956659ea76421d2d80936cd14ad510.tar.xz
Handle no action specified
Previously, bash would handle shifting the empty ${@} when no command was specified, but sh should break with error "shift: nothing to shift". Now we handle if no command is specified, by printing an error (action required...) and returning code 1 before executing the shift.
-rwxr-xr-xandbackup.sh10
1 files changed, 7 insertions, 3 deletions
diff --git a/andbackup.sh b/andbackup.sh
index 3bcc064..4296973 100755
--- a/andbackup.sh
+++ b/andbackup.sh
@@ -90,8 +90,6 @@ backup_app() {
local origifs=${IFS} # Input field seperator at runtime. Useful for
# reverting
- local tar # Tar command for packaging the backup
-
# Make sure app is specified
if [[ -z ${app} ]]; then
lerror "Application name required."
@@ -311,7 +309,13 @@ verify_system() {
main() {
- local cmd=${1:-}
+ local cmd="${1:-}"
+
+ if [ -z "${cmd:-}" ]; then
+ printf "Action required (backup, listbackup, restore, listrestore)\n"
+ return 1
+ fi
+
shift
if [ "${cmd}" = 'help' ]; then

Generated by cgit