diff --git a/doc_src/and.txt b/doc_src/and.txt index 0b4f681d1..ce09285f1 100644 --- a/doc_src/and.txt +++ b/doc_src/and.txt @@ -7,11 +7,12 @@ COMMAND1; and COMMAND2 \subsection and-description Description -`and` is used to execute a command if the current exit status (as set by the last previous command) is 0. +`and` is used to execute a command if the current exit status (as set by the previous command) is 0. -`and` does not change the current exit status. +`and` statements may be used as part of the condition in an `and` or `while` block. See the documentation +for `if` and `while` for examples. -The exit status of the last foreground command to exit can always be accessed using the $status variable. +`and` does not change the current exit status. The exit status of the last foreground command to exit can always be accessed using the $status variable. \subsection and-example Example diff --git a/doc_src/if.txt b/doc_src/if.txt index 1cecdcd35..a30b10110 100644 --- a/doc_src/if.txt +++ b/doc_src/if.txt @@ -12,7 +12,7 @@ end `if` will execute the command `CONDITION`. If the condition's exit status is 0, the commands `COMMANDS_TRUE` will execute. If the exit status is not 0 and `else` is given, `COMMANDS_FALSE` will be executed. -In order to use the exit status of multiple commands as the condition of an if block, use `begin; ...; end` and the short circuit commands `and` and `or`. +You can use `and` or `or` in the condition. See the second example below. The exit status of the last foreground command to exit can always be accessed using the $status variable. @@ -33,9 +33,8 @@ end The following code will print "foo.txt exists and is readable" if foo.txt is a regular file and readable \fish -if begin test -f foo.txt - and test -r foo.txt - end +if test -f foo.txt + and test -r foo.txt echo "foo.txt exists and is readable" end \endfish diff --git a/doc_src/or.txt b/doc_src/or.txt index 1cd1d768e..97707e064 100644 --- a/doc_src/or.txt +++ b/doc_src/or.txt @@ -7,12 +7,12 @@ COMMAND1; or COMMAND2 \subsection or-description Description -`or` is used to execute a command if the current exit status (as set by the last previous command) is not 0. +`or` is used to execute a command if the current exit status (as set by the previous command) is not 0. -`or` does not change the current exit status. - -The exit status of the last foreground command to exit can always be accessed using the $status variable. +`or` statements may be used as part of the condition in an `and` or `while` block. See the documentation +for `if` and `while` for examples. +`or` does not change the current exit status. The exit status of the last foreground command to exit can always be accessed using the $status variable. \subsection or-example Example diff --git a/doc_src/while.txt b/doc_src/while.txt index c06874d59..855edce11 100644 --- a/doc_src/while.txt +++ b/doc_src/while.txt @@ -11,12 +11,11 @@ while CONDITION; COMMANDS...; end If the exit status of `CONDITION` is non-zero on the first iteration, `COMMANDS` will not be executed at all. -Use `begin; ...; end` for complex conditions; more complex control can be achieved with `while true` containing a break. - +You can use `and` or `or` for complex conditions. Even more complex control can be achieved with `while true` containing a break. \subsection while-example Example \fish -while test -f foo.txt; echo file exists; sleep 10; end -# outputs 'file exists' at 10 second intervals as long as the file foo.txt exists. -\endfish \ No newline at end of file +while test -f foo.txt; or test -f bar.txt ; echo file exists; sleep 10; end +# outputs 'file exists' at 10 second intervals as long as the file foo.txt or bar.txt exists. +\endfish