From 820e4021d3474d6d11d8847be8b2ae9b24da72d8 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 25 Jul 2017 20:58:47 -0400 Subject: [PATCH] stdenv-setup: Remove any `declare -g` This is invalid before bash-4.2, affecting bash used impurely in nix-shell on MacOS. --- pkgs/stdenv/generic/setup.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 1e8b5f57585a..dc3369f6611c 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -285,10 +285,7 @@ findInputs() { *" $pkg "*) return 0 ;; esac - # For some reason, bash gives us some (hopefully limited) eval - # "for free"! Everything is single-quoted except for `"$var"` - # so `var` is expanded first. - declare -g "$var"'=("${'"$var"'[@]}" "$pkg")' + eval "$var"'+=("$pkg")' if ! [ -e "$pkg" ]; then echo "build input $pkg does not exist" >&2 @@ -318,19 +315,19 @@ findInputs() { if [ -z "$crossConfig" ]; then # Not cross-compiling - both buildInputs (and variants like propagatedBuildInputs) # are handled identically to nativeBuildInputs - declare -ga nativePkgs + declare -a nativePkgs for i in $nativeBuildInputs $buildInputs \ $defaultNativeBuildInputs $defaultBuildInputs \ $propagatedNativeBuildInputs $propagatedBuildInputs; do findInputs "$i" nativePkgs propagated-native-build-inputs done else - declare -ga crossPkgs + declare -a crossPkgs for i in $buildInputs $defaultBuildInputs $propagatedBuildInputs; do findInputs "$i" crossPkgs propagated-build-inputs done - declare -ga nativePkgs + declare -a nativePkgs for i in $nativeBuildInputs $defaultNativeBuildInputs $propagatedNativeBuildInputs; do findInputs "$i" nativePkgs propagated-native-build-inputs done