Useful or not, from you.
shellcheck Bad Advice on Replacing "which" with "command -v" - Not Equivalent

For bugs

  • Rule Id: SC2230

  • My shellcheck version (shellcheck --version or "online"): version: 0.5.0

  • [X ] The rule's wiki page does not already cover this (e.g.

  • [ X] I tried on and verified that this is still a problem on the latest commit

Here's a snippet or screenshot that shows the problem:

Screenshot from 2019-09-28 12-28-30

Here's what shellcheck currently says:

SEQ_CMD="$(which seq)"||MISSING_CMDS+=("seq");declare -r SEQ_CMD ^-- SC2230: which is non-standard. Use builtin 'command -v' instead.

Here's what I wanted or expected to see:

Using command -v vs which is probably bad advice. For instance if an alias exists for a command and you issue a "which command" you will get the full path to the first version in the PATH variable found. If you issue a command -v you will get the alias if one exists. These two commands are not interchangeable.

Try: $> alias cp='_(){ ((${#}==1)) && cp -nv "${1}" "$(pwd)" || cp -nv "${1}" "${2}";};_' now, you can see the difference: $> which cp /bin/cp $> command -v cp alias cp='(){ ((${#}==1)) && cp -nv "${1}" "$(pwd)" || cp -nv "${1}" "${2}";};'

When you are using which to set help set command path variables you don't want it loaded with alias declarations.

That's a useful answer
Without any help

See also: #1162