From 3ce3e50053b5b3a512b6ea528826c104ddf296fa Mon Sep 17 00:00:00 2001 From: Victor Engmark Date: Tue, 9 Nov 2021 10:55:40 +0000 Subject: [PATCH] Quote variable references (#144838) * pkgs/build-support: Quote variable name * pkgs/build-support: Quote variable reference * pkgs/build-support: Quote variable references Leads to a minor behavior change: there's no trailing space in the output when `[[ "$linkType" == "static-pie" ]]` is true. --- pkgs/build-support/wrapper-common/utils.bash | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkgs/build-support/wrapper-common/utils.bash b/pkgs/build-support/wrapper-common/utils.bash index 4658c9e74248..0afccadf3384 100644 --- a/pkgs/build-support/wrapper-common/utils.bash +++ b/pkgs/build-support/wrapper-common/utils.bash @@ -21,13 +21,13 @@ mangleVarListGeneric() { local -a role_suffixes=("$@") local outputVar="${var}_@suffixSalt@" - declare -gx ${outputVar}+='' + declare -gx "$outputVar"+='' # For each role we serve, we accumulate the input parameters into our own # cc-wrapper-derivation-specific environment variables. for suffix in "${role_suffixes[@]}"; do local inputVar="${var}${suffix}" if [ -v "$inputVar" ]; then - export ${outputVar}+="${!outputVar:+$sep}${!inputVar}" + export "${outputVar}+=${!outputVar:+$sep}${!inputVar}" fi done } @@ -42,7 +42,7 @@ mangleVarBool() { local -a role_suffixes=("$@") local outputVar="${var}_@suffixSalt@" - declare -gxi ${outputVar}+=0 + declare -gxi "${outputVar}+=0" for suffix in "${role_suffixes[@]}"; do local inputVar="${var}${suffix}" if [ -v "$inputVar" ]; then @@ -146,7 +146,7 @@ checkLinkType() { # When building static-pie executables we cannot have rpath # set. At least glibc requires rpath to be empty filterRpathFlags() { - local linkType=$1 ret="" i + local linkType=$1 ret i shift if [[ "$linkType" == "static-pie" ]]; then @@ -156,11 +156,11 @@ filterRpathFlags() { # also skip its argument shift else - ret+="$i " + ret+=("$i") fi done else - ret=$@ + ret=("$@") fi - echo $ret + echo "${ret[@]}" }