Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Question about getopts in 3.0.2



I tried reading the FAQ.  Didn't see anything pertaining to this.

I'm having trouble using getopts in the case where it requires an argument:

while getopts :G2rd: OPT
do
  case $OPT in
   '2'|'r'|'G') GENARG=($GENARG -$OPT) ;;
    'd') echo printer is $OPTARG ;; #LPARG=-d$OPTARG ;;
    '?') echo $0:t: Unknown option $OPTARG; exit 1 ;; 
    ':') echo $0:t: Option required for $OPTARG; exit 1 ;;
  esac
done

In the case of d, OPTARG is generally unusable/trashed when I don't think
it should be.  For example, lp -dlwfoo produces a null OPTARG and lp -d
lwfoo produces and error "Unknown option l".  What am I doing wrong?

Thanks,

-Clint



Messages sorted by: Reverse Date, Date, Thread, Author