diff options
author | Mark Griffiths <mark@thebespokepixel.com> | 2014-09-03 15:10:53 +0100 |
---|---|---|
committer | Mark Griffiths <mark@thebespokepixel.com> | 2014-09-03 15:10:53 +0100 |
commit | adbcecb456bc74f7a58dfae3daef0c7a45cd8d32 (patch) | |
tree | 8c5b677207e29246fe03b169bed45f6f4b795c3e /doc_src/test.txt | |
parent | 3df9e20ca762584d68df1f7c507592264acf83aa (diff) |
Rebase documentation changes
Diffstat (limited to 'doc_src/test.txt')
-rw-r--r-- | doc_src/test.txt | 59 |
1 files changed, 25 insertions, 34 deletions
diff --git a/doc_src/test.txt b/doc_src/test.txt index 101cda97..632e7901 100644 --- a/doc_src/test.txt +++ b/doc_src/test.txt @@ -7,9 +7,7 @@ test [EXPRESSION] \subsection test-description Description -Tests the expression given and sets the exit status to 0 if true, -and 1 if false. An expression is made up of one or more operators -and their arguments. +Tests the expression given and sets the exit status to 0 if true, and 1 if false. An expression is made up of one or more operators and their arguments. The following operators are available to examine files and directories: @@ -24,11 +22,13 @@ The following operators are available to examine files and directories: - `-f FILE` returns true if `FILE` is a regular file. - `-g FILE` returns true if `FILE` has the set-group-ID bit set. -- `-G FILE` returns true if `FILE` exists and has the same group ID -as the current user. + +- `-G FILE` returns true if `FILE` exists and has the same group ID as the current user. + - `-L FILE` returns true if `FILE` is a symbolic link. -- `-O FILE` returns true if `FILE` exists and is owned by the current -user. + +- `-O FILE` returns true if `FILE` exists and is owned by the current user. + - `-p FILE` returns true if `FILE` is a named pipe. - `-r FILE` returns true if `FILE` is marked as readable. @@ -46,10 +46,11 @@ user. - `-x FILE` returns true if `FILE` is marked as executable. The following operators are available to compare and examine text strings: -- `STRING1 = STRING2` returns true if the strings `STRING1` and -`STRING2` are identical. -- `STRING1 != STRING2` returns true if the strings `STRING1` and -`STRING2` are not identical. + +- `STRING1 = STRING2` returns true if the strings `STRING1` and `STRING2` are identical. + +- `STRING1 != STRING2` returns true if the strings `STRING1` and `STRING2` are not identical. + - `-n STRING` returns true if the length of `STRING` is non-zero. - `-z STRING` returns true if the length of `STRING` is zero. @@ -68,9 +69,7 @@ The following operators are available to compare and examine numbers: - `NUM1 -le NUM2` returns true if `NUM1` is less than or equal to `NUM2`. -Note that only integers are supported. For more complex mathematical -operations, including fractions, the `env` program may be useful. Consult the -documentation for your operating system. +Note that only integers are supported. For more complex mathematical operations, including fractions, the `env` program may be useful. Consult the documentation for your operating system. Expressions can be combined using the following operators: @@ -79,14 +78,15 @@ Expressions can be combined using the following operators: - `COND1 -o COND2` returns true if either `COND1` or `COND2` are true. Expressions can be inverted using the `!` operator: -- `! EXPRESSION` returns true if `EXPRESSION` is false, and false if -`EXPRESSION` is true. + +- `! EXPRESSION` returns true if `EXPRESSION` is false, and false if `EXPRESSION` is true. Expressions can be grouped using parentheses. - `( EXPRESSION )` returns the value of `EXPRESSION`. -Note that parentheses will usually require escaping with `\\(` to avoid -being interpreted as a command substitution. + + Note that parentheses will usually require escaping with `\(` to avoid being interpreted as a command substitution. + \subsection test-example Examples @@ -98,19 +98,15 @@ if test -d /tmp end \endfish -If the variable \c MANPATH is defined and not empty, print the contents. -(If \c MANPATH is not defined, then it will expand to zero arguments, unless -quoted.) +If the variable `MANPATH` is defined and not empty, print the contents. (If `MANPATH` is not defined, then it will expand to zero arguments, unless quoted.) -<pre> +\fish if test -n "$MANPATH" echo $MANPATH end \endfish -Parentheses and the `-o` and `-a` operators can be combined to produce -more complicated expressions. In this example, success is printed if there is -a `/foo` or `/bar` file as well as a `/baz` or `/bat` file. +Parentheses and the `-o` and `-a` operators can be combined to produce more complicated expressions. In this example, success is printed if there is a `/foo` or `/bar` file as well as a `/baz` or `/bat` file. \fish if test \( -f /foo -o -f /bar \) -a \( -f /baz -o -f /bat \) @@ -121,15 +117,10 @@ end. \subsection test-standards Standards -`test` implements a subset of the -<a href="http://www.unix.com/man-page/POSIX/1/test/">IEEE Std 1003.1-2008 -(POSIX.1) standard</a>. The following exceptions apply: +`test` implements a subset of the <a href="http://www.unix.com/man-page/POSIX/1/test/">IEEE Std 1003.1-2008 (POSIX.1) standard</a>. The following exceptions apply: + - The `<` and `>` operators for comparing strings are not implemented. -- Because this test is a shell builtin and not a standalone utility, using - the -c flag on a special file descriptors like standard input and output - may not return the same result when invoked from within a pipe as one - would expect when invoking the `test` utility in another shell. - In cases such as this, one can use `command` `test` to explicitly - use the system's standalone `test` rather than this `builtin` `test`. +- Because this test is a shell builtin and not a standalone utility, using the -c flag on a special file descriptors like standard input and output may not return the same result when invoked from within a pipe as one would expect when invoking the `test` utility in another shell. + In cases such as this, one can use `command` `test` to explicitly use the system's standalone `test` rather than this `builtin` `test`. |