Conditionally perform a command.
Syntax switch (string) case str1: ... breaksw ... default: ... breaksw endsw
Each case label is successively matched, against the specified string which is first command and filename expanded.
The file metacharacters `*', `?' and `[...]' may be used in the case labels, which are variable expanded.
If none of the labels match before a `default' label is found, then the execution begins after the default label.
Each case label and the default label must appear at the beginning of a line. The command breaksw causes execution to continue after the endsw. Otherwise control may fall through case labels and default labels as in C.
If no label matches and there is no default, execution continues
after the endsw.
“The most important thing in an argument, next to being right, is to leave an escape hatch for your opponent, so that he can gracefully swing over to your side without too much apparent loss of face” ~ Sydney J. Harris
Related macOS commands:
continue - Resume the next iteration of a while or if loop.
for - Loop, expand words, and execute commands
if - Conditionally perform a command
while - Execute commands