/usr/share/fish/man/man1/switch.1 is in fish-common 2.4.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | .TH "switch" 1 "Sun Dec 11 2016" "Version 2.4.0" "fish" \" -*- nroff -*-
.ad l
.nh
.SH NAME
\fBswitch\fP -- conditionally execute a block of commands
.PP
.SS "Synopsis"
.PP
.nf
\fBswitch\fP VALUE; [\fBcase\fP [WILDCARD\&.\&.\&.]; [COMMANDS\&.\&.\&.]; \&.\&.\&.] \fBend\fP
.fi
.PP
.SS "Description"
\fCswitch\fP performs one of several blocks of commands, depending on whether a specified value equals one of several wildcarded values\&. \fCcase\fP is used together with the \fCswitch\fP statement in order to determine which block should be executed\&.
.PP
Each \fCcase\fP command is given one or more parameters\&. The first \fCcase\fP command with a parameter that matches the string specified in the switch command will be evaluated\&. \fCcase\fP parameters may contain wildcards\&. These need to be escaped or quoted in order to avoid regular wildcard expansion using filenames\&.
.PP
Note that fish does not fall through on case statements\&. Only the first matching case is executed\&.
.PP
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\&.
.SS "Example"
If the variable $animal contains the name of an animal, the following code would attempt to classify it:
.PP
.PP
.nf
\fBswitch\fP $animal
\fBcase\fP cat
\fBecho\fP evil
\fBcase\fP wolf dog human moose dolphin whale
\fBecho\fP mammal
\fBcase\fP duck goose albatross
\fBecho\fP bird
\fBcase\fP shark trout stingray
\fBecho\fP fish
\fBcase\fP '*'
\fBecho\fP I have no idea what a $animal is
\fBend\fP
.fi
.PP
.PP
If the above code was run with \fC$animal\fP set to \fCwhale\fP, the output would be \fCmammal\fP\&.
|