diff options
author | Kerin Millar <kfm@plushkava.net> | 2024-08-08 18:06:08 +0100 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2024-08-11 11:11:00 +0100 |
commit | 8b747094a6444a02631706922ee572493ed4caab (patch) | |
tree | caf6c7737ee60b237da2c4cccefa81ab7b0bb2ac /functions.sh | |
parent | test-functions: choose a better variable name for storing the temp dir (diff) | |
download | gentoo-functions-8b747094a6444a02631706922ee572493ed4caab.tar.gz gentoo-functions-8b747094a6444a02631706922ee572493ed4caab.tar.bz2 gentoo-functions-8b747094a6444a02631706922ee572493ed4caab.zip |
Rename quote_args_bash() to _quote_args_bash()
For it need not be in the public name space.
Signed-off-by: Kerin Millar <kfm@plushkava.net>
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'functions.sh')
-rw-r--r-- | functions.sh | 45 |
1 files 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 @@ -732,6 +712,29 @@ _has_dumb_terminal() } # +# 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(). # _select_by_mtime() |