Copyedited, added links to POSIX

Lawrence Velázquez
2024-03-08 19:43:55 -05:00
parent 9798448ea8
commit 6708aaa197

@@ -12,8 +12,7 @@ fi
### Correct code:
Either switch to bash:
Either switch to bash or ksh, or use:
```sh
#!/bin/sh
if [ -n "${STY+x}" ]
@@ -26,7 +25,7 @@ fi
Your script uses a shell feature not supported by the shebang. Either rewrite the script to be portable, or change the shebang to explicitly require a shell like Bash.
In this case, `[ -v variable ]` to check if a variable is set can be replaced with `[ -n "${variable+x}" ]` which uses the "alternative value if set" parameter expansion syntax to accomplish the same thing.
In this case, `[ -v variable ]`, which checks if a variable is set, is [not specified by POSIX](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html). It can be replaced with the portable `[ -n "${variable+x}" ]`, which uses the "alternative value if set" [parameter expansion](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02) syntax to accomplish the same thing.
### Exceptions: