#!/bin/csh # Demonstration of a switch control structure. # This routine tests the first command-line argument # for yes or no in any combination of upper- and # lowercase letters. # # test that argv[1] exists if ($#argv != 1) then echo "Usage: switch_1 [yes|no]" exit 1 else # argv[1] exists, set up switch based on its value switch ($argv[1]) # case of YES case [yY][eE][sS]: echo "Argument one is yes." breaksw # # case of NO case [nN][oO]: echo "Argument one is no." breaksw # # default case default: echo "Argument one is neither yes nor no." breaksw endsw endif