Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F161687123
D57892.id180806.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D57892.id180806.diff
View Options
diff --git a/bin/test/test.1 b/bin/test/test.1
--- a/bin/test/test.1
+++ b/bin/test/test.1
@@ -33,7 +33,7 @@
.Dt TEST 1
.Os
.Sh NAME
-.Nm test ,
+.Nm test
.Nm \&[
.Nd condition evaluation utility
.Sh SYNOPSIS
@@ -106,7 +106,7 @@
True if
.Ar file
is a named pipe
-.Pq Tn FIFO .
+.Pq FIFO
.It Fl r Ar file
True if
.Ar file
@@ -267,6 +267,27 @@
True if
.Ar expression
is false.
+.El
+.Pp
+The following binary operators are available for use:
+.Bl -tag -width Ar
+.It Ar expression1 && Ar expression2
+True if both
+.Ar expression1
+and
+.Ar expression2
+are true.
+.It Ar expression1 || Ar expression2
+True if either
+.Ar expression1
+or
+.Ar expression2
+are true.
+.El
+The \fI&&\fP operator and \fI||\fP operator have equal precedence in the shell.
+.Pp
+Historically the following operators were also commonly used:
+.Bl -tag -width Ar
.It Ar expression1 Fl a Ar expression2
True if both
.Ar expression1
@@ -282,39 +303,6 @@
.It Cm \&( Ar expression Cm \&)
True if expression is true.
.El
-.Pp
-The
-.Fl a
-operator has higher precedence than the
-.Fl o
-operator.
-.Pp
-Some shells may provide a builtin
-.Nm
-command which is similar or identical to this utility.
-Consult the
-.Xr builtin 1
-manual page.
-.Sh GRAMMAR AMBIGUITY
-The
-.Nm
-grammar is inherently ambiguous.
-In order to assure a degree of consistency,
-the cases described in the
-.St -p1003.2 ,
-section D11.2/4.62.4, standard
-are evaluated consistently according to the rules specified in the
-standards document.
-All other cases are subject to the ambiguity in the
-command semantics.
-.Pp
-In particular, only expressions containing
-.Fl a ,
-.Fl o ,
-.Cm \&(
-or
-.Cm \&)
-can be ambiguous.
.Sh EXIT STATUS
The
.Nm
@@ -328,20 +316,44 @@
.It >1
An error occurred.
.El
-.Sh EXAMPLES
+.Sh CAVEATS
+Expressions containing
+.Fl a ,
+.Fl o ,
+.Cm \&(
+or
+.Cm \&)
+can be ambiguous.
+.Pp
+The legacy
+.Fl a
+operator also had higher precedence than the legacy
+.Fl o
+operator.
+.Pp
+Scripts using these legacy forms should be converted to use
+.Cm &&
+and
+.Cm ||
+instead.
+.Pp
Implement
.Li test FILE1 -nt FILE2
-using only
-.Tn POSIX
-functionality:
+using only POSIX functionality:
.Pp
.Dl test -n \&"$(find -L -- FILE1 -prune -newer FILE2 2>/dev/null)\&"
.Pp
-This can be modified using non-standard
-.Xr find 1
-primaries like
-.Cm -newerca
-to compare other timestamps.
+The
+.Nm
+grammar is inherently ambiguous.
+In order to assure a degree of consistency,
+the cases described in the
+.St -p1003.2 ,
+section D11.2/4.62.4, standard
+are evaluated consistently according to the rules specified in the
+standards document.
+All other cases are subject to the ambiguity in the
+command semantics.
.Sh COMPATIBILITY
For compatibility with some other implementations,
the
@@ -349,6 +361,13 @@
primary can be substituted with
.Cm ==
with the same meaning.
+.Pp
+Some shells may provide a builtin
+.Nm
+command which is similar or identical to this utility.
+Consult the
+.Xr builtin 1
+manual page.
.Sh SEE ALSO
.Xr builtin 1 ,
.Xr expr 1 ,
@@ -373,20 +392,20 @@
and
.Fl O
are extensions.
+.Pp
+The
+.Fl a
+and
+.Fl o
+binary primaries and
+.Cm \&(
+and
+.Cm \&)
+operators were marked obsolescent in the 2008 POSIX standards and removed
+in the 2024 POSIX standards, their portability and continued
+long-term support cannot be guaranteed.
.Sh HISTORY
A
.Nm
utility appeared in
.At v7 .
-.Sh BUGS
-Both sides are always evaluated in
-.Fl a
-and
-.Fl o .
-For instance, the writable status of
-.Pa file
-will be tested by the following command even though the former expression
-indicated false, which results in a gratuitous access to the file system:
-.Dl "[ -z abc -a -w file ]"
-To avoid this, write
-.Dl "[ -z abc ] && [ -w file ]"
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jul 6, 11:12 PM (13 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34430348
Default Alt Text
D57892.id180806.diff (3 KB)
Attached To
Mode
D57892: test.1: Add note regarding -a,-o and () obsolecence
Attached
Detach File
Event Timeline
Log In to Comment