The list of option specifications is terminated with a single minus (-); the arguments to be parsed follow this. When the argument parsing has finished the environment variable $* is set to the remaining list of arguments.
#!/dis/sh load arg bflag := cflag := 0 file := () args := $* (arg bc {$opt^flag = 1} f+ {file=$arg} r++++ {rect=$arg} '*' {echo unknown option $opt} - $args ) echo $0 $bflag $cflag $file echo rect $rect echo arguments are $*
When invoked as follows:
the output is:
./script 1 1 file rect 0 10 50 100 arguments are a b c
and when invoked by:
the output is:
unknown option z ./script 1 0 file arguments are -bc
SH-ARG(1 ) | Rev: Tue Mar 31 02:42:38 GMT 2015 |