Skip to content

Commit

Permalink
add args variable for capturing script.sh arguments before they are c…
Browse files Browse the repository at this point in the history
…onsumed by getopts, adjust debug command to display how script.sh was run
  • Loading branch information
Tylerjet committed Sep 16, 2024
1 parent f7bb520 commit ec52cb6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -78,15 +80,15 @@ 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

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

Expand Down

0 comments on commit ec52cb6

Please sign in to comment.