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 8F6AE159C9B for ; Sun, 11 Aug 2024 10:11:17 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 9F9492BC0AA; Sun, 11 Aug 2024 10:11:14 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.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 8A5C62BC0AA for ; Sun, 11 Aug 2024 10:11:14 +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 70060343118 for ; Sun, 11 Aug 2024 10:11:13 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 8A4211EEA for ; Sun, 11 Aug 2024 10:11:10 +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: <1723371060.8b747094a6444a02631706922ee572493ed4caab.sam@gentoo> Subject: [gentoo-commits] proj/gentoo-functions:master commit in: / X-VCS-Repository: proj/gentoo-functions X-VCS-Files: functions.sh X-VCS-Directories: / X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 8b747094a6444a02631706922ee572493ed4caab X-VCS-Branch: master Date: Sun, 11 Aug 2024 10:11:10 +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: 6bd093e0-c03a-4b11-a500-ebd9c9b70af4 X-Archives-Hash: 5c45774ca1f8acc8486151a25f5173c4 commit: 8b747094a6444a02631706922ee572493ed4caab Author: Kerin Millar plushkava net> AuthorDate: Thu Aug 8 17:06:08 2024 +0000 Commit: Sam James gentoo org> CommitDate: Sun Aug 11 10:11:00 2024 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=8b747094 Rename quote_args_bash() to _quote_args_bash() For it need not be in the public name space. Signed-off-by: Kerin Millar plushkava.net> Signed-off-by: Sam James gentoo.org> functions.sh | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/functions.sh b/functions.sh index a111f12..78830c6 100644 --- a/functions.sh +++ b/functions.sh @@ -410,7 +410,7 @@ quote_args() # Call into a bash-optimised implementation where appropriate. # shellcheck disable=3028 if [ ! "${POSIXLY_CORRECT}" ] && [ "${BASH_VERSINFO-0}" -ge 5 ]; then - quote_args_bash "$@" + _quote_args_bash "$@" return fi LC_ALL=C awk -v q=\' -f - -- "$@" <<-'EOF' @@ -468,26 +468,6 @@ quote_args() EOF } -# shellcheck disable=3028 -if [ "${BASH_VERSINFO-0}" -ge 5 ]; then - # Note that the ${parameter@Q} form of expansion is supported as of - # bash 4.4. However, it is simpler to test for 5.0 or greater in sh. - eval ' - quote_args_bash() { - local IFS=" " args i - - (( $# > 0 )) || return 0 - args=("${@@Q}") - for i in "${!args[@]}"; do - if [[ ${args[i]} == \$* ]]; then - args[i]=${args[i]//\\E/\\e} - fi - done - printf "%s\\n" "${args[*]}" - } - ' -fi - # # Generates a random number between 0 and 2147483647 (2^31-1) with the # assistance of the kernel CSPRNG. Upon success, the number shall be printed to @@ -731,6 +711,29 @@ _has_dumb_terminal() ! case ${TERM} in *dumb*) false ;; esac } +# +# Potentially called by quote_args(), duly acting as a bash-optimised variant. +# It leverages the ${paramater@Q} form of expansion, which is supported as of +# bash 4.4. However, it is simpler just to test for 5.0 or greater in sh. +# +# shellcheck disable=3028 +if [ "${BASH_VERSINFO-0}" -ge 5 ]; then + eval ' + _quote_args_bash() { + local IFS=" " args i + + (( $# > 0 )) || return 0 + args=("${@@Q}") + for i in "${!args[@]}"; do + if [[ ${args[i]} == \$* ]]; then + args[i]=${args[i]//\\E/\\e} + fi + done + printf "%s\\n" "${args[*]}" + } + ' +fi + # # See the definitions of oldest() and newest(). #