Skip to content

no-which

Shellstyleno fixdefault: offshell/shellcheck

Reports a call of which.

which is not part of POSIX, and its output and exit status differ between systems (some print an error message and exit 0). command -v is built into the shell and is portable.

To fix, write command -v name.

Reported
...
which git
...
test -f x && echo yes || echo no
[ -n x ] && (a || b)
a && b
a || b && c
...
which git
shell:
lint:
rules:
no-which: warn # off (default), warn, error

Enabled by the presets: shell/shellcheck.

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

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
shellcheck SC2230 full