diff options
-rw-r--r-- | doc/coreutils.texi | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/doc/coreutils.texi b/doc/coreutils.texi index fc83a87c3..05dcd668b 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -8692,15 +8692,36 @@ expression must be a separate argument. @command{test} has file status checks, string operators, and numeric comparison operators. +@command{test} has an alternate form that uses opening and closing +square brackets instead a leading @samp{test}. For example, instead +of @samp{test -d /}, you can write @samp{[ -d / ]}. The square +brackets must be separate arguments; for example, @samp{[-d /]} does +not have the desired effect. Since @samp{test @var{expr}} and @samp{[ +@var{expr} ]} have the same meaning, only the former form is discussed +below. + @cindex conflicts with shell built-ins @cindex built-in shell commands, conflicts with Because most shells have a built-in command by the same name, using the unadorned command name in a script or interactively may get you different functionality than that described here. -Besides the options below, @command{test} accepts a lone @option{--help} or -@option{--version}. @xref{Common options}. A single non-option argument -is also allowed: @command{test} returns true if the argument is not null. +Besides the options below, a single argument is also allowed: +@command{test} returns true if the argument is not null. The argument +can be any string, including strings like @samp{-d}, @samp{-1}, +@samp{--}, @samp{--help}, and @samp{--version} that most other +programs would treat as options. To get help and version information, +invoke the commands @samp{[ --help} and @samp{[ --version}, without +the usual closing brackets. @xref{Common options}. + +@cindex exit status of @command{test} +Exit status: + +@display +0 if the expression is true, +1 if the expression is false, +2 if an error occurred. +@end display @menu * File type tests:: -[bcdfhLpSt] @@ -8759,11 +8780,11 @@ True if @var{file} exists and is a named pipe. @cindex socket check True if @var{file} exists and is a socket. -@item -t [@var{fd}] +@item -t @var{fd} @opindex -t @cindex terminal check -True if @var{fd} is opened on a terminal. If @var{fd} is omitted, it -defaults to 1 (standard output). +True if @var{fd} is a file descriptor that is associated with a +terminal. @end table |