Skip to content

unset-glob

Shellsuspiciousno fixdefault: offshell/shellcheck

Reports unset name[i] with an unquoted subscript.

The word name[i] is a glob pattern too. If a file called namei exists in the directory, the shell replaces the word with it and unsets that name.

To fix, quote it: unset 'name[i]'.

Reported
...
IFS= read -r line
PGHOST=db psql
unset words[0]
unset "words[0]"
...
[[ $a == "$b" ]]
...
shell:
lint:
rules:
unset-glob: warn # off (default), warn, error

Enabled by the presets: shell/shellcheck.

Suppress one line with sudsy-disable-next-line unset-glob in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
shellcheck SC2184 partial Only unset name[...].