aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc_src
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2016-05-19 13:00:40 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2016-05-19 13:01:12 -0700
commit30ea7cc3f8a5d56ad30dc749ea374363c15f312a (patch)
tree93d6ec24f73cd82906ab1c8c622451c3f62a9524 /doc_src
parent573b3797a507c3912197ebd4f2df0dc0398d3826 (diff)
Update docs to reflect new if/while condtion chaining
Documents new behavior in #1428
Diffstat (limited to 'doc_src')
-rw-r--r--doc_src/and.txt7
-rw-r--r--doc_src/if.txt7
-rw-r--r--doc_src/or.txt8
-rw-r--r--doc_src/while.txt9
4 files changed, 15 insertions, 16 deletions
diff --git a/doc_src/and.txt b/doc_src/and.txt
index 0b4f681d..ce09285f 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 <a href="#if">`and`</a> or <a href="#while">`while`</a> block. See the documentation
+for <a href="#if">`if`</a> and <a href="#while">`while`</a> for examples.
-The exit status of the last foreground command to exit can always be accessed using the <a href="index.html#variables-status">$status</a> 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 <a href="index.html#variables-status">$status</a> variable.
\subsection and-example Example
diff --git a/doc_src/if.txt b/doc_src/if.txt
index 1cecdcd3..a30b1011 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 <a href="#begin">`begin; ...; end`</a> and the short circuit commands <a href="commands.html#and">`and`</a> and <a href="commands.html#or">`or`</a>.
+You can use <a href="#and">`and`</a> or <a href="#and">`or`</a> in the condition. See the second example below.
The exit status of the last foreground command to exit can always be accessed using the <a href="index.html#variables-status">$status</a> 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 1cd1d768..97707e06 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 <a href="index.html#variables-status">$status</a> variable.
+`or` statements may be used as part of the condition in an <a href="#if">`and`</a> or <a href="#while">`while`</a> block. See the documentation
+for <a href="#if">`if`</a> and <a href="#while">`while`</a> 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 <a href="index.html#variables-status">$status</a> variable.
\subsection or-example Example
diff --git a/doc_src/while.txt b/doc_src/while.txt
index c06874d5..855edce1 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 <a href="#begin">`begin; ...; end`</a> for complex conditions; more complex control can be achieved with `while true` containing a <a href="#break">break</a>.
-
+You can use <a href="#and">`and`</a> or <a href="#and">`or`</a> for complex conditions. Even more complex control can be achieved with `while true` containing a <a href="#break">break</a>.
\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