Table of Contents

# $EPIC: getopt.txt,v 1.4 2007/03/02 02:32:04 jnelson Exp $

Synopsis:

$getopt(<optopt-var> <optarg-var> <option-list> <argument-list>)

Technical:

Practical:

Useful when you want an alias to accept option flags and you need a way to parse them easily. See the example section for particulars.

Returns:

See technical specification for return values.

Examples:

alias myalias {
  while (option = getopt(optopt optarg "ab:c:" $*)) {
    switch ($option) {
      (a) {echo * option "$optopt" used}
      (b) {echo * option "$optopt" used - $optarg}
      (c) {echo * option "$optopt" used - $optarg}
      (!) {echo * option "$optopt" is an invalid option}
      (-) {echo * option "$optopt" is missing an argument}
    }
  }
  echo * remaining args: $optarg
}