test(1): Clarify grammar ambiguity and -a/-o vs shell &&/||.
This commit is contained in:
parent
3f97220f48
commit
d26fd835e7
@ -32,7 +32,7 @@
|
|||||||
.\" @(#)test.1 8.1 (Berkeley) 5/31/93
|
.\" @(#)test.1 8.1 (Berkeley) 5/31/93
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd July 31, 2006
|
.Dd September 10, 2010
|
||||||
.Dt TEST 1
|
.Dt TEST 1
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -310,6 +310,14 @@ are evaluated consistently according to the rules specified in the
|
|||||||
standards document.
|
standards document.
|
||||||
All other cases are subject to the ambiguity in the
|
All other cases are subject to the ambiguity in the
|
||||||
command semantics.
|
command semantics.
|
||||||
|
.Pp
|
||||||
|
In particular, only expressions containing
|
||||||
|
.Fl a ,
|
||||||
|
.Fl o ,
|
||||||
|
.Cm \&(
|
||||||
|
or
|
||||||
|
.Cm \&)
|
||||||
|
can be ambiguous.
|
||||||
.Sh EXIT STATUS
|
.Sh EXIT STATUS
|
||||||
The
|
The
|
||||||
.Nm
|
.Nm
|
||||||
@ -338,12 +346,11 @@ specification.
|
|||||||
Both sides are always evaluated in
|
Both sides are always evaluated in
|
||||||
.Fl a
|
.Fl a
|
||||||
and
|
and
|
||||||
.Fl o ,
|
.Fl o .
|
||||||
unlike in the logical operators of
|
|
||||||
.Xr sh 1 .
|
|
||||||
For instance, the writable status of
|
For instance, the writable status of
|
||||||
.Pa file
|
.Pa file
|
||||||
will be tested by the following command even though the former expression
|
will be tested by the following command even though the former expression
|
||||||
indicated false, which results in a gratuitous access to the file system:
|
indicated false, which results in a gratuitous access to the file system:
|
||||||
.Pp
|
|
||||||
.Dl "[ -z abc -a -w file ]"
|
.Dl "[ -z abc -a -w file ]"
|
||||||
|
To avoid this, write
|
||||||
|
.Dl "[ -z abc ] && [ -w file ]"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user