diff options
author | 2024-06-04 04:23:10 +0100 | |
---|---|---|
committer | 2024-06-12 08:06:42 +0100 | |
commit | 5e599c75905b04918ce7d7fdaa9dfd845c322d8e (patch) | |
tree | 34614417bd1730746fe772f6086271269912e0fa | |
parent | Add the GENFUN_API_LEVEL variable declaration (diff) | |
download | gentoo-functions-5e599c75905b04918ce7d7fdaa9dfd845c322d8e.tar.gz gentoo-functions-5e599c75905b04918ce7d7fdaa9dfd845c322d8e.tar.bz2 gentoo-functions-5e599c75905b04918ce7d7fdaa9dfd845c322d8e.zip |
Promote _print_args() to the public function, quote_args()
Signed-off-by: Kerin Millar <kfm@plushkava.net>
-rw-r--r-- | functions.sh | 6 | ||||
-rwxr-xr-x | test-functions | 28 |
2 files changed, 17 insertions, 17 deletions
diff --git a/functions.sh b/functions.sh index a0315f9..a9af6b6 100644 --- a/functions.sh +++ b/functions.sh @@ -95,7 +95,7 @@ ebegin() # edo() { - genfun_cmd=$(_print_args "$@") + genfun_cmd=$(quote_args "$@") einfo "Executing: ${genfun_cmd}" "$@" || die "Failed to execute command: ${genfun_cmd}" } @@ -844,7 +844,7 @@ _is_visible() # of the ${*@Q} expansion in bash. The output shall be POSIX sh compatible as of # Issue 8. This should probably be made to exist as a standalone awk script. # -_print_args() +quote_args() { awk -v q=\' -f - -- "$@" <<-'EOF' BEGIN { @@ -963,7 +963,7 @@ _warn_for_args() ident=$1 shift [ "$#" -gt 1 ] && plural=s || plural= - warn "${ident}: invalid argument${plural}: $(_print_args "$@")" + warn "${ident}: invalid argument${plural}: $(quote_args "$@")" } # All function declarations end here! Initialisation code only from hereon. diff --git a/test-functions b/test-functions index ed3da42..1a2eb81 100755 --- a/test-functions +++ b/test-functions @@ -41,7 +41,7 @@ test_chdir() { callback() { shift - test_description="chdir $(_print_args "$@")" + test_description="chdir $(quote_args "$@")" if [ "$BASH" ]; then # shellcheck disable=3044 shopt -s cdable_vars @@ -60,7 +60,7 @@ test_chdir_noop() { callback() { shift - test_description="chdir $(_print_args "$@")" + test_description="chdir $(quote_args "$@")" chdir "$@" \ && test "$PWD" = "$OLDPWD" \ || { cd - >/dev/null; false; } @@ -194,7 +194,7 @@ test_is_older_than() { callback() { shift - test_description="is_older_than $(_print_args "$@")" + test_description="is_older_than $(quote_args "$@")" is_older_than "$@" } @@ -220,7 +220,7 @@ test_get_bootparam() { callback() { cmdline=$2 shift 2 - test_description="get_bootparam $(_print_args "$@")" + test_description="get_bootparam $(quote_args "$@")" printf '%s\n' "${cmdline}" | get_bootparam "$@" } @@ -244,7 +244,7 @@ test_esyslog() { callback() { should_log=$2 shift 2 - test_description="esyslog $(_print_args "$@")" + test_description="esyslog $(quote_args "$@")" logged=$(EINFO_LOG=1 esyslog "$@") case $? in 0) @@ -306,7 +306,7 @@ test_is_identifier() { callback() { shift - test_description="is_identifier $(_print_args "$@")" + test_description="is_identifier $(quote_args "$@")" is_identifier "$@" } @@ -331,7 +331,7 @@ test_is_int() { callback() { shift - test_description="is_int $(_print_args "$@")" + test_description="is_int $(quote_args "$@")" is_int "$@" } @@ -351,7 +351,7 @@ test_is_visible() { callback() { shift - test_description="_is_visible $(_print_args "$@")" + test_description="_is_visible $(quote_args "$@")" _is_visible "$@" } @@ -390,7 +390,7 @@ test_yesno() { callback() { shift - test_description="yesno $(_print_args "$@")" + test_description="yesno $(quote_args "$@")" yesno "$@" } @@ -441,7 +441,7 @@ test_newest() { callback() { shift - test_description="newest $(_print_args "$@")" + test_description="newest $(quote_args "$@")" row=$(( row + 1 )) true | if [ "${row}" -le 2 ]; then @@ -477,7 +477,7 @@ test_trim() { callback() { shift - test_description="trim $(_print_args "$1") (expecting $(_print_args "$2"))" + test_description="trim $(quote_args "$1") (expecting $(quote_args "$2"))" test "$(trim "$1")" = "$2" } @@ -500,7 +500,7 @@ test_hr() { shift expected=$1 shift - test_description="hr $(_print_args "$@")" + test_description="hr $(quote_args "$@")" test "$(hr "$@")" = "${expected}" } @@ -533,7 +533,7 @@ test_whenceforth() { shift path=$1 shift - test_description="whenceforth $(_print_args "$@")" + test_description="whenceforth $(quote_args "$@")" if [ "${path}" = PATH ]; then whenceforth "$@" >/dev/null else @@ -568,7 +568,7 @@ test_parallel_run() { callback() { shift - test_description="parallel_run $(_print_args 0 ls "$@")" + test_description="parallel_run $(quote_args 0 ls "$@")" parallel_run 0 ls "$@" >/dev/null 2>&1 } |