From 798cdbda54eaf4acd8766413bb17287edf71756c Mon Sep 17 00:00:00 2001 From: Mingye Wang Date: Mon, 12 Apr 2021 19:16:33 +0800 Subject: [PATCH] Updated SC2166 (markdown) --- SC2166.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SC2166.md b/SC2166.md index 4d2281b..1bd14c2 100644 --- a/SC2166.md +++ b/SC2166.md @@ -15,7 +15,6 @@ And likewise, prefer `[ p ] || [ q ]` over `[ p -o q ]`. ``` - ### 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): @@ -34,3 +33,6 @@ Using multiple `[ .. ]` expressions with shell AND/OR operators `&&` and `||` is ### 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). + +### See also: +* [Problems With the test Builtin: What Does -a Mean?](http://www.oilshell.org/blog/2017/08/31.html) \ No newline at end of file