Help get this topic noticed by sharing it on Twitter, Facebook, or email.

Trying to use --man option with getopts

I'm trying to implement something similar to the phaser4 example in appendix B of the Learning the Korn Shell Book. Basically, I'm trying to be able to use character options passed in on the command line combined with the --man capability as shown in Appendix B, like this:

#! /bin/ksh

USAGE=$'[-?\n@(#)$Id: Star_Trek_Monsters (Starfleet Research and Development)'
USAGE+=$' Stardate 57234.22 $\n]'
USAGE+="[-copyright?Copyright (c) Stardate 57000 Starfleet.]"
USAGE+="[+DESCRIPTION?The Star_Trek_Monsters program allows the selection of Star Trek Monsters"
USAGE+=" in one handy tool.]"

USAGE+="[M:Mon*ster]:[Monster:=Salt Monster?Select the Star Trek Monster.]{
[Salt_Monster?From the First Broadcast Episode]
[Gorn?Guy in the Rubber Suit]

USAGE+=$'[+SEE ALSO?\aphaser3\a(1), \atricorder\a(1)]'


while getopts "$USAGE" optchar ; do
case $optchar in

print Monster=$Monster

Here's the output:

$ Star_Trek_Monsters.ksh -M Gorn
Star_Trek_Monsters.ksh -M Gorn
Star_Trek_Monsters.ksh: -M: Gorn: unknown option argument value
Usage: Star_Trek_Monsters.ksh [-M Monster]

Sorry if this is obvous...
1 person has
this question