diff --git a/SC3006.md b/SC3006.md new file mode 100644 index 0000000..4b8aed5 --- /dev/null +++ b/SC3006.md @@ -0,0 +1,23 @@ +## In POSIX sh, standalone ((..)) is undefined. + +### Problematic code: + +```sh +variable=1 +if ((variable)); then + echo variable is not zero +fi +``` + +### Correct code: + +[`bash` supports standalone `((..))`](https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html#index-select) natively. + +For POSIX compliance, use + +```sh +variable=1 +if [ "${variable}" -ne 0 ]; then + echo variable is not zero +fi +``` \ No newline at end of file