-
-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
…array remove implicit array comparison in case
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -364,16 +364,13 @@ findInputs() { | |
local var="${!varRef}" | ||
unset -v varVar varRef | ||
|
||
# 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 | ||
# 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 | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
happysalada
Author
Contributor
|
||
return 0 | ||
fi | ||
|
||
eval "$var"'+=("$pkg")' | ||
|
||
|
The issue here is that you're comparing
foo[*]
here instead of the actual content. What the original code did in pseudocode was:I tried to come up with a less ugly way then we had before, but didn't succeed.
@Ericson2314: Maybe you got a better idea? :-)