Skip to content

Commit

Permalink
pkgs/stdenv/generic/setup.sh: lint with ShellCheck
Browse files Browse the repository at this point in the history
The behaviour of [[ -n/-z "${FOO[@]}" ]] is unspecified.
Use [[ -n/-z "${FOO[*]-}" ]] instead
  • Loading branch information
ShamrockLee committed Oct 28, 2024
1 parent 5d11433 commit 6c73c49
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkgs/stdenv/generic/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ shopt -s inherit_errexit
# $NIX_DEBUG must be a documented integer level, if set, so we can use it safely as an integer.
# See the `Verbosity` enum in the Nix source for these levels.
if ! [[ -z ${NIX_DEBUG-} || $NIX_DEBUG == [0-7] ]]; then
# shellcheck disable=SC2016
printf 'The `NIX_DEBUG` environment variable has an unexpected value: %s\n' "${NIX_DEBUG}"
echo "It can only be unset or an integer between 0 and 7."
exit 1
Expand Down Expand Up @@ -396,7 +397,7 @@ concatTo() {
for arg in "$@"; do
IFS="=" read -r name default <<< "$arg"
local -n nameref="$name"
if [[ ! -n "${nameref[@]}" && -n "$default" ]]; then
if [[ -z "${nameref[*]-}" && -n "${default-}" ]]; then
targetref+=( "$default" )
elif type=$(declare -p "$name" 2> /dev/null); then
case "${type#* }" in
Expand Down

0 comments on commit 6c73c49

Please sign in to comment.