From bc266dc94a50fa474b44aee7eb1e1a92ae34ca35 Mon Sep 17 00:00:00 2001 From: Dominic Ricottone Date: Thu, 29 Sep 2022 10:56:08 -0500 Subject: [PATCH] Use standard arg parser --- core/debom | 36 +----------------------------------- core/myparse.bash | 6 +++--- core/rebom | 37 +------------------------------------ 3 files changed, 5 insertions(+), 74 deletions(-) diff --git a/core/debom b/core/debom index f6e7197..ea2bd39 100755 --- a/core/debom +++ b/core/debom @@ -13,41 +13,7 @@ read -r -d '' help_message <<-EOF EOF source /usr/local/lib/mylib.bash - -positional=() -quiet=0 -verbose=0 -while [[ $# -gt 0 ]]; do - case "$1" in - - -h|--help) - help_msg - shift - ;; - - -q|--quiet) - debug_msg "Setting quiet option to 1 (was ${quiet})" - quiet=1 - shift - ;; - - -v|--verbose) - debug_msg "Setting verbose option to 1 (was ${verbose})" - verbose=1 - shift - ;; - - -V|--version) - version_msg - ;; - - *) - debug_msg "Argument '${1}' added to positional array" - positional+=("$1") - shift - ;; - esac -done +. /usr/local/lib/myparse.bash # error if no filenames given if [[ ${#positional[@]} -eq 0 ]]; then diff --git a/core/myparse.bash b/core/myparse.bash index 78dbf89..15f9e9a 100755 --- a/core/myparse.bash +++ b/core/myparse.bash @@ -9,7 +9,7 @@ quiet=0 verbose=0 while [[ $# -gt 0 ]]; do - case $1 in + case "$1" in -h|--help) help_msg @@ -17,13 +17,13 @@ while [[ $# -gt 0 ]]; do ;; -q|--quiet) - debug_msg "Setting QUIET option to 1 (was ${quiet})" + debug_msg "Setting quiet option to 1 (was ${quiet})" quiet=1 shift ;; -v|--verbose) - debug_msg "Setting VERBOSE option to 1 (was ${verbose})" + debug_msg "Setting verbose option to 1 (was ${verbose})" verbose=1 shift ;; diff --git a/core/rebom b/core/rebom index 3e8e853..86f2a3c 100755 --- a/core/rebom +++ b/core/rebom @@ -13,42 +13,7 @@ read -r -d '' help_message <<-EOF EOF source /usr/local/lib/mylib.bash - -positional=() -quiet=0 -verbose=0 -while [[ $# -gt 0 ]]; do - case "$1" in - - -h|--help) - help_msg - shift - ;; - - -q|--quiet) - debug_msg "Setting quiet option to 1 (was ${quiet})" - quiet=1 - shift - ;; - - -v|--verbose) - debug_msg "Setting verbose option to 1 (was ${verbose})" - verbose=1 - shift - ;; - - -V|--version) - version_msg - shift - ;; - - *) - debug_msg "Argument '${1}' added to positional array" - positional+=("$1") - shift - ;; - esac -done +. /usr/local/lib/myparse.bash # error if no filenames given if [[ ${#positional[@]} -eq 0 ]]; then -- 2.45.2