diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2017-07-06 19:29:48 -0400 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2017-07-07 11:35:09 -0400 |
commit | a14cf0618219a6f135e786e69e78eb0b866248f8 (patch) | |
tree | 627dbe35513cd2009ea1a6a766b9dc01e032bb4f /pkgs/stdenv/generic/setup.sh | |
parent | 74f55017d26bb0931184bbcb54630000ce5ee107 (diff) |
stdenv: Harden hook runners
Instead of eval, use a "nameref" to get the name of the array and iterate with that. Also, make the for-loop parameter a local variable, too.
Diffstat (limited to 'pkgs/stdenv/generic/setup.sh')
-rw-r--r-- | pkgs/stdenv/generic/setup.sh | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index eb63b18e5f3dc..191abf7596bd9 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -17,8 +17,9 @@ runHook() { shift local var="$hookName" if [[ "$hookName" =~ Hook$ ]]; then var+=s; else var+=Hooks; fi - eval "local -a dummy=(\"\${$var[@]}\")" - for hook in "_callImplicitHook 0 $hookName" "${dummy[@]}"; do + local -n var + local hook + for hook in "_callImplicitHook 0 $hookName" "${var[@]}"; do _eval "$hook" "$@" done return 0 @@ -32,8 +33,9 @@ runOneHook() { shift local var="$hookName" if [[ "$hookName" =~ Hook$ ]]; then var+=s; else var+=Hooks; fi - eval "local -a dummy=(\"\${$var[@]}\")" - for hook in "_callImplicitHook 1 $hookName" "${dummy[@]}"; do + local -n var + local hook + for hook in "_callImplicitHook 1 $hookName" "${var[@]}"; do if _eval "$hook" "$@"; then return 0 fi |