diff --git a/SC2230.md b/SC2230.md new file mode 100644 index 0000000..dd93d49 --- /dev/null +++ b/SC2230.md @@ -0,0 +1,25 @@ +## which is non-standard. Use builtin 'command -v' instead. + +### Problematic code: + +```sh +which grep +``` + +### Correct code: + +```sh +command -v grep +``` + +### Rationale: + +`which` is a non-standard, external tool that locates an executable in PATH. `command -v` is a POSIX standard builtin, which uses the same lookup mechanism that the shell itself would. + +### Exceptions: + +None + +### Related resources: + +* [Check if a program exists from a Bash script](https://stackoverflow.com/a/677212/1899640) on StackOverflow. \ No newline at end of file