From ec52cb675971bcbebb1a4354d716b3eee6c0d634 Mon Sep 17 00:00:00 2001 From: MrTylerjet Date: Sun, 15 Sep 2024 22:43:35 -0600 Subject: [PATCH] add args variable for capturing script.sh arguments before they are consumed by getopts, adjust debug command to display how script.sh was run --- script.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/script.sh b/script.sh index c5dd796..07df72a 100755 --- a/script.sh +++ b/script.sh @@ -35,6 +35,8 @@ exclude=${exclude:-"*.swp" "*.tmp" "printer-[0-9]*_[0-9]*.cfg" "*.bak" "*.bkp" " # Required for checking the use of the commit_message and debug parameter commit_message_used=false debug_output=false +# Collect args before they are consumed by getopts +args="$@" # Check parameters while [[ $# -gt 0 ]]; do @@ -78,7 +80,7 @@ if [[ ! -v backupPaths ]]; then if bash $parent_path/utils/v1convert.sh; then echo "Upgrade complete restarting script.sh" sleep 2.5 - exec "$parent_path/script.sh" "$@" + exec "$parent_path/script.sh" "$args" fi fi @@ -86,7 +88,7 @@ if [ "$debug_output" = true ]; then # Debug output: Show last command begin_debug_line if [[ "$SHELL" == */bash* ]]; then - echo -n "Command: " && tail -n 3 ~/.bash_history | head -n 1 + echo -n "Command: $0 $args" fi end_debug_line