From 6f239d7309690153b181479735d9a254dfa2fcc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Sun, 11 Jul 2021 16:02:17 +0200 Subject: [PATCH] Revert "setup.sh: fatal: This word should yield a string, but it contains an array" This reverts commit bf99a819a16089a8df03cc06262f06b31dfb683c. It caused regressions in some packages; see: https://github.com/NixOS/nixpkgs/commit/bf99a819a160 --- pkgs/stdenv/generic/setup.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 3515439337c6..4ae561fbca07 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -368,13 +368,16 @@ findInputs() { local var="${!varRef}" unset -v varVar varRef - # var is a reference to an array and can sometimes be undefined - # so checking the array with "${!var}[@]" does not work - # check if $pkgs is in the var ref array - # TODO(@Ericson2314): Restore using associative array - if [[ "${var}[*]" = *" $pkg "* ]]; then - return 0 - fi + # TODO(@Ericson2314): Restore using associative array once Darwin + # nix-shell doesn't use impure bash. This should replace the O(n) + # case with an O(1) hash map lookup, assuming bash is implemented + # well :D. + local varSlice="${var}[*]" + # ${..-} to hack around old bash empty array problem + case "${!varSlice-}" in + *" $pkg "*) return 0 ;; + esac + unset -v varSlice eval "$var"'+=("$pkg")'