0

Background

In bash I have a working getopts interface as depicted below:

while getopts "a:b:c:d:" OPTION ; do
    case "$OPTION" in
        a) JET="$OPTARG" ;;
        b) FUEL="$OPTARG" ;;
        c) CAN="$OPTARG" ;;
        d) MELT="$OPTARG" ;;
        *) echo "Usage $0 -a A -b B -c C -d D"; exit 1 ;;
    esac
done
shift $((OPTIND-1))

#Check out input parameters
for PARAM in JET FUEL CAN MELT; do
    echo "$PARAM in [${!PARAM}]"
done

Question

What is the cshell translation for this? I cannot find a clear example of getopts (with an s) in cshell, yet there is an easily findable one for bash. This is distinct from attempting to use getopt, since getopts is an entirely different function from getopt.

isakbob
  • 1,439
  • 2
  • 17
  • 39
  • Two sources state that getopts is not available for csh. https://www3.physnet.uni-hamburg.de/physnet/Tru64-Unix/HTML/MAN/MAN1/0221____.HTM https://aplawrence.com/Unix/getopts.html – Gonen I Jun 14 '19 at 18:51
  • 1
    "Easier to use and generally better than getopt, though of course not available in csh-like shells. You shouldn't be using those anyway." Oof, that hit me right in kernel. – isakbob Jun 14 '19 at 19:00

0 Answers0