1

Problem

I am trying to make a chshell script that takes in user input from several options. Inspired by this bash example, I tried to construct a while loop and switch case statement pattern around the getopt command. After several iterations I have tried to interpret this example from IBM:

set argv=`getopt :a:b:c:d:e: $*`

if ($? != 0) then
    exit 1
endif
while ({ ` $1 != --` })
    switch ($1)
        case[-a]:
            yada
            breaksw
        case[-b]:
            yada
            breaksw
        case[-c]:
            yada
            breaksw
        case[-d]:
            yada
            breaksw
        case[-e]:
            yada
            breaksw           
        default:
            yada default
            breaksw
     ends
end
shift

It returns the error: -a: Command not found.

Question

How do I correctly and efficiently use getopt in cshell without reinventing the wheel and essentially recopying the underlying getopt code?

isakbob
  • 1,439
  • 2
  • 17
  • 39

0 Answers0