Merge pull request #159394 from talyz/make-wrapper-dont-glob

makeWrapper: Don't glob in prefix/suffix

authored by Guillaume Girol and committed by GitHub 184432f4 9b116ea7

+20 -1
+17 -1
pkgs/build-support/setup-hooks/make-wrapper.sh
··· 51 local varName="$2" # name of list variable to add to 52 local separator="$3" # character used to separate elements of list 53 local value="$4" # one value, or multiple values separated by `separator`, to add to list 54 - if test -n "$value"; then 55 local old_ifs=$IFS 56 IFS=$separator 57 ··· 85 } >> "$wrapper" 86 done 87 IFS=$old_ifs 88 fi 89 } 90
··· 51 local varName="$2" # name of list variable to add to 52 local separator="$3" # character used to separate elements of list 53 local value="$4" # one value, or multiple values separated by `separator`, to add to list 54 + 55 + # Disable file globbing, since bash will otherwise try to find 56 + # filenames matching the the value to be prefixed/suffixed if 57 + # it contains characters considered wildcards, such as `?` and 58 + # `*`. We want the value as is, except we also want to split 59 + # it on on the separator; hence we can't quote it. 60 + local reenableGlob=0 61 + if [[ ! -o noglob ]]; then 62 + reenableGlob=1 63 + fi 64 + set -o noglob 65 + 66 + if [[ -n "$value" ]]; then 67 local old_ifs=$IFS 68 IFS=$separator 69 ··· 97 } >> "$wrapper" 98 done 99 IFS=$old_ifs 100 + fi 101 + 102 + if (( reenableGlob )); then 103 + set +o noglob 104 fi 105 } 106
+3
pkgs/test/make-wrapper/default.nix
··· 64 (mkWrapperBinary { name = "test-run-and-set"; args = [ "--run" "export VAR=foo" "--set" "VAR" "bar" ]; }) 65 (mkWrapperBinary { name = "test-args"; args = [ "--add-flags" "abc" ]; wrapped = wrappedBinaryArgs; }) 66 (mkWrapperBinary { name = "test-prefix"; args = [ "--prefix" "VAR" ":" "abc" ]; }) 67 (mkWrapperBinary { name = "test-suffix"; args = [ "--suffix" "VAR" ":" "abc" ]; }) 68 (mkWrapperBinary { name = "test-prefix-and-suffix"; args = [ "--prefix" "VAR" ":" "foo" "--suffix" "VAR" ":" "bar" ]; }) 69 (mkWrapperBinary { name = "test-prefix-multi"; args = [ "--prefix" "VAR" ":" "abc:foo:foo" ]; }) ··· 112 # Only append the value once when given multiple times in a parameter 113 # to makeWrapper 114 + mkTest "test-prefix" "VAR=abc" 115 116 117 # --suffix works
··· 64 (mkWrapperBinary { name = "test-run-and-set"; args = [ "--run" "export VAR=foo" "--set" "VAR" "bar" ]; }) 65 (mkWrapperBinary { name = "test-args"; args = [ "--add-flags" "abc" ]; wrapped = wrappedBinaryArgs; }) 66 (mkWrapperBinary { name = "test-prefix"; args = [ "--prefix" "VAR" ":" "abc" ]; }) 67 + (mkWrapperBinary { name = "test-prefix-noglob"; args = [ "--prefix" "VAR" ":" "./*" ]; }) 68 (mkWrapperBinary { name = "test-suffix"; args = [ "--suffix" "VAR" ":" "abc" ]; }) 69 (mkWrapperBinary { name = "test-prefix-and-suffix"; args = [ "--prefix" "VAR" ":" "foo" "--suffix" "VAR" ":" "bar" ]; }) 70 (mkWrapperBinary { name = "test-prefix-multi"; args = [ "--prefix" "VAR" ":" "abc:foo:foo" ]; }) ··· 113 # Only append the value once when given multiple times in a parameter 114 # to makeWrapper 115 + mkTest "test-prefix" "VAR=abc" 116 + # --prefix doesn't expand globs 117 + + mkTest "VAR=f?oo test-prefix-noglob" "VAR=./*:f?oo" 118 119 120 # --suffix works