From 56873621bdc7203169e7dbf1d49027f23d7c4ff4 Mon Sep 17 00:00:00 2001 From: Arnaud Rebillout Date: Mon, 4 Mar 2024 08:36:01 +0700 Subject: [PATCH] Quote arguments where needs be, in debug logs Before, looks like that: RUNNING: build-simple-cdd --verbose --debug --force-root --conf simple-cdd.conf --dist kali-rolling --debian-mirror http://kali.download/kali/ --profiles kali offline --auto-profiles kali offline After, looks like that: RUNNING: build-simple-cdd --verbose --debug --force-root --conf simple-cdd.conf --dist kali-rolling --debian-mirror http://kali.download/kali/ --profiles 'kali offline' --auto-profiles 'kali offline' --- build.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index be5372a..10055e8 100755 --- a/build.sh +++ b/build.sh @@ -94,7 +94,11 @@ failure() { run_and_log() { if [ -n "$VERBOSE" ] || [ -n "$DEBUG" ]; then - echo "RUNNING: $@" >&2 + printf "RUNNING:" >&2 + for _ in "$@"; do + [[ $_ =~ [[:space:]] ]] && printf " '%s'" "$_" || printf " %s" "$_" + done >&2 + printf "\n" >&2 "$@" 2>&1 | tee -a "$BUILD_LOG" else "$@" >>"$BUILD_LOG" 2>&1