From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 0AD0715817D for ; Fri, 21 Jun 2024 13:14:23 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id CB670E2A7D; Fri, 21 Jun 2024 13:14:19 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id ABAC3E2A56 for ; Fri, 21 Jun 2024 13:14:19 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D139A33BF29 for ; Fri, 21 Jun 2024 13:14:17 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 2BECC1D55 for ; Fri, 21 Jun 2024 13:14:15 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1718176002.5e599c75905b04918ce7d7fdaa9dfd845c322d8e.sam@gentoo> Subject: [gentoo-commits] proj/gentoo-functions:master commit in: / X-VCS-Repository: proj/gentoo-functions X-VCS-Files: functions.sh test-functions X-VCS-Directories: / X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 5e599c75905b04918ce7d7fdaa9dfd845c322d8e X-VCS-Branch: master Date: Fri, 21 Jun 2024 13:14:15 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 5e47dd31-ffb0-478c-80db-568c143184bd X-Archives-Hash: 0edebc4f2d87b2f3f4bfa7d6e012f07b commit: 5e599c75905b04918ce7d7fdaa9dfd845c322d8e Author: Kerin Millar plushkava net> AuthorDate: Tue Jun 4 03:23:10 2024 +0000 Commit: Sam James gentoo org> CommitDate: Wed Jun 12 07:06:42 2024 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=5e599c75 Promote _print_args() to the public function, quote_args() Signed-off-by: Kerin Millar plushkava.net> functions.sh | 6 +++--- 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 }