Case command

The syntax of the case command is

case word in

pattern1 ) list1 ;;

pattern2 | pattern3 ) list2 ;;

...

esac

qsh expands each pattern in turn and sees if it matches the expansion of word. When there is a match, qsh runs the corresponding list. After the first match, no more patterns are expanded. See "Shell Patterns" for more details on patterns.

Examples

  1. A case command for processing command line options.
    while getopts ap:t: c ; do
      case $c in
        a) aflag=1;;
        p) pflag=1
           path=$OPTARG;;
        t) time=$OPTARG;;
        *) print -u2 "Invalid option"
           exit 1;;
      esac
    done