2012-07-03 21:54:00 +00:00
|
|
|
\section test test - perform tests on files and text
|
|
|
|
|
|
|
|
\subsection test-synopsis Synopsis
|
|
|
|
<tt>test [EXPRESSION]</tt>
|
|
|
|
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 07:56:01 +00:00
|
|
|
\subsection test-description Description
|
2012-07-03 21:54:00 +00:00
|
|
|
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 07:56:01 +00:00
|
|
|
Tests the expression given and sets the exit status to 0 if true,
|
|
|
|
and 1 if false.
|
|
|
|
|
|
|
|
The following options are available:
|
|
|
|
- \c -h displays a help message and then exits.
|
|
|
|
- <tt>-L FILE</tt> returns true if \c FILE is a symbolic link.
|
|
|
|
- <tt>-S FILE</tt> returns true if \c FILE is a socket.
|
|
|
|
- <tt>COND1 -a COND2</tt> combines two conditions with a logical and.
|
|
|
|
- <tt>-b FILE</tt> returns true if \c FILE is a block device.
|
|
|
|
- <tt>-c FILE</tt> returns true if \c FILE is a character device.
|
|
|
|
- <tt>-d FILE</tt> returns true if \c FILE is a directory.
|
|
|
|
- <tt>-e FILE</tt> returns true if \c FILE exists.
|
|
|
|
- <tt>-f FILE</tt> returns true if \c FILE is a regular file.
|
|
|
|
- <tt>-f FILE</tt> returns true if \c FILE has set-group-ID bit set.
|
|
|
|
- <tt>-n STRING</tt> returns true if the length of \c STRING is non-zero.
|
|
|
|
- <tt>COND1 -o COND2</tt> combines two conditions with a logical or.
|
|
|
|
- <tt>-p FILE</tt> returns true if \c FILE is a named pipe.
|
|
|
|
- <tt>-r FILE</tt> returns true if \c FILE is readable.
|
|
|
|
- <tt>-s FILE</tt> returns true if the size of \c FILE is non-zero.
|
|
|
|
- <tt>-t FD</tt> returns true if \c FD is a terminal (TTY).
|
|
|
|
- <tt>-u FILE</tt> returns true if \c FILE has set-user-ID bit set.
|
|
|
|
- <tt>-w FILE</tt> returns true if \c FILE is writable.
|
|
|
|
- <tt>-x FILE</tt> returns true if \c FILE is executable.
|
|
|
|
- <tt>-z STRING</tt> returns true if \c STRING length is zero.
|
2012-07-03 21:54:00 +00:00
|
|
|
|
|
|
|
\subsection test-example Example
|
|
|
|
|
2012-11-05 01:38:42 +00:00
|
|
|
<pre>
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 07:56:01 +00:00
|
|
|
if test -d "/"
|
|
|
|
echo "Fish is cool"
|
|
|
|
end
|
2012-11-05 01:38:42 +00:00
|
|
|
</pre>
|
2012-07-03 21:54:00 +00:00
|
|
|
|
Help cleanup
Large list of changes, including formatting and typos for most commands.
More substantive changes have been made to alias, bind, block, break,
builtin, case, cd, commandline, count, else, emit, fish_config, funced,
function, functions, history, math, mimedb, nextd, not, popd, prevd,
pushd, pwd, random, read, set, set_color, switch, test, trap, type,
ulimit, umask, and while.
2013-05-12 07:56:01 +00:00
|
|
|
Because "/" is a directory, the expression will evaluate to true, and
|
|
|
|
"Fish is cool" will be output.
|