mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Updated SC2166 (markdown)
@@ -15,7 +15,6 @@ And likewise, prefer `[ p ] || [ q ]` over `[ p -o q ]`.
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Rationale:
|
### Rationale:
|
||||||
|
|
||||||
`-a` and `-o` to mean AND and OR in a `[ .. ]` test expression is not well defined, and can cause incorrect results when arguments start with dashes or contain `!`. [From POSIX](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html):
|
`-a` and `-o` to mean AND and OR in a `[ .. ]` test expression is not well defined, and can cause incorrect results when arguments start with dashes or contain `!`. [From POSIX](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html):
|
||||||
@@ -34,3 +33,6 @@ Using multiple `[ .. ]` expressions with shell AND/OR operators `&&` and `||` is
|
|||||||
### Exceptions:
|
### Exceptions:
|
||||||
|
|
||||||
If the shell variant being used is ksh derived (such as the bash shell) it will have the shell builtin command `[[ ... ]]`. This has the operators `&&`, `||`, `(`, `)`, `!` which safely avoid the ambiguity by noting which arguments were quoted and requiring the operators to be unquoted (except by the `[[ ... ]]` construct itself).
|
If the shell variant being used is ksh derived (such as the bash shell) it will have the shell builtin command `[[ ... ]]`. This has the operators `&&`, `||`, `(`, `)`, `!` which safely avoid the ambiguity by noting which arguments were quoted and requiring the operators to be unquoted (except by the `[[ ... ]]` construct itself).
|
||||||
|
|
||||||
|
### See also:
|
||||||
|
* [Problems With the test Builtin: What Does -a Mean?](http://www.oilshell.org/blog/2017/08/31.html)
|
Reference in New Issue
Block a user