create for documenting POSIX shell’s undefined standalone ((..))

Lucas Larson
2021-05-14 20:25:29 -04:00
parent d66281ad50
commit 496c09573a

23
SC3006.md Normal file

@@ -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
```