aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc_src/case.txt
diff options
context:
space:
mode:
authorGravatar David Adam (zanchey) <zanchey@ucc.gu.uwa.edu.au>2013-05-12 15:56:01 +0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-05-13 01:48:20 -0700
commit1287b9d82382bf22e16edda67eae755f07397f2e (patch)
tree811814b029d65ac11a193e616ca4a71d216dbe0c /doc_src/case.txt
parent91aab03b90a6b583a3c0ecff5b015c6066d34f28 (diff)
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.
Diffstat (limited to 'doc_src/case.txt')
-rw-r--r--doc_src/case.txt26
1 files changed, 12 insertions, 14 deletions
diff --git a/doc_src/case.txt b/doc_src/case.txt
index 468cc3c4..b5601cdb 100644
--- a/doc_src/case.txt
+++ b/doc_src/case.txt
@@ -5,27 +5,24 @@
\subsection case-description Description
-The \c switch statement is used to perform one of several blocks of
-commands depending on whether a specified value equals one of several
-wildcarded values. The \c case statement is used together with the \c
-switch statement in order to determine which block should be
-performed.
+\c switch performs one of several blocks of commands, depending on whether
+a specified value equals one of several wildcarded values. \c case is used
+together with the \c switch statement in order to determine which block should
+be executed.
-Each \c case command is given one or more parameter. The first \c case
+Each \c case command is given one or more parameters. The first \c case
command with a parameter that matches the string specified in the
switch command will be evaluated. \c case parameters may contain
wildcards. These need to be escaped or quoted in order to avoid
regular wildcard expansion using filenames.
-Note that fish does not fall through on case statements. Though the
-syntax may look a bit like C switch statements, it behaves more like
-the case statements of traditional shells.
+Note that fish does not fall through on case statements. Only the
+first matching case is executed.
-Also note that command substitutions in a case statement will be
-evaluated even if it's body is not taken. This may seem
-counterintuitive at first, but it is unavoidable, since it would be
-impossible to know if a case command will evaluate to true before all
-forms of parameter expansion have been performed for the case command.
+Note that command substitutions in a case statement will be
+evaluated even if its body is not taken. All substitutions, including
+command substitutions, must be performed before the value can be compared
+against the parameter.
\subsection case-example Example
@@ -42,6 +39,7 @@ switch $animal
echo bird
case shark trout stingray
echo fish
+ # Note that the next case has a wildcard which is quoted
case '*'
echo I have no idea what a $animal is
end