On 21.10. 20:03, Chet Ramey wrote:
The help text for test says

"The behavior of test depends on the number of arguments.  Read the
bash manual page for the complete specification."

Can I suggest adding that note from the help text to the manual under "Bash Conditional Expressions" too? Perhaps also explicitly noting the clash with the binary operators in the descriptions of -a and -o, too.

Something along the lines of the attached patch.

I also think the description of the 3-argument test would be clearer with numbering, so I added that too.

--
Ilkka Virta / itvi...@iki.fi
--- bashref.texi.orig   2018-10-21 20:45:31.909941736 +0300
+++ bashref.texi        2018-10-21 21:09:24.302551079 +0300
@@ -3795,18 +3795,25 @@
 
 @item 3 arguments
 The following conditions are applied in the order listed.
+
+@enumerate
+@item
 If the second argument is one of the binary conditional
 operators (@pxref{Bash Conditional Expressions}), the
 result of the expression is the result of the binary test using the
 first and third arguments as operands.
 The @samp{-a} and @samp{-o} operators are considered binary operators
 when there are three arguments.
+@item
 If the first argument is @samp{!}, the value is the negation of
 the two-argument test using the second and third arguments.
+@item
 If the first argument is exactly @samp{(} and the third argument is
 exactly @samp{)}, the result is the one-argument test of the second
 argument.
+@item
 Otherwise, the expression is false.
+@end enumerate
 
 @item 4 arguments
 If the first argument is @samp{!}, the result is the negation of
@@ -6821,7 +6828,9 @@
 @cindex expressions, conditional
 
 Conditional expressions are used by the @code{[[} compound command
-and the @code{test} and @code{[} builtin commands.
+and the @code{test} and @code{[} builtin commands. The behavior of
+the @code{test} and @code{[} builtins depend on the number of arguments.
+See their descriptions in @ref{Bourne Shell Builtins} for details.
 
 Expressions may be unary or binary.
 Unary expressions are often used to examine the status of a file.
@@ -6846,7 +6855,8 @@
 
 @table @code
 @item -a @var{file}
-True if @var{file} exists.
+True if @var{file} exists. Note that this may be interpreted as the binary
+@samp{-a} operator if used with the @code{test} or @code{[} builtins.
 
 @item -b @var{file}
 True if @var{file} exists and is a block special file.
@@ -6924,6 +6934,8 @@
 True if the shell option @var{optname} is enabled.
 The list of options appears in the description of the @option{-o}
 option to the @code{set} builtin (@pxref{The Set Builtin}).
+Note that this may be interpreted as the binary @samp{-o} operator
+if used with the @code{test} or @code{[} builtins.
 
 @item -v @var{varname}
 True if the shell variable @var{varname} is set (has been assigned a value).

Reply via email to