Revert "setup.sh: fatal: This word should yield a string, but it contains an array"

This reverts commit bf99a819a1.
It caused regressions in some packages; see:
https://github.com/NixOS/nixpkgs/commit/bf99a819a160
This commit is contained in:
Vladimír Čunát 2021-07-11 16:02:17 +02:00
parent 3ea417e47f
commit 6f239d7309
No known key found for this signature in database
GPG key ID: E747DF1F9575A3AA

View file

@ -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")'