1

Have been using getopt for some time. I am looking into the possibility of having two argument values for an option. Is this good and possible to do this with getopt. An example would help.

Have done some tests and figured out that doing

myfunc -S 13 21

gives

opts:  -S '13' -- '21'

where

opts=$( getopt -o "$shortopts" -l "$longopts" -n "${0##*/}" -- "$@" )

Thusly getopt is incapable of accepting myfunc -S 13 21.

Dilna
  • 405
  • 1
  • 6

1 Answers1

1

I am handling things this way

 while (( $# > 0 )); do
   case $1 in
    ("-S"|"--seam")
      [[ "$2" = +([[:digit:]]) ]] && { sp="$2" ; shift ; }
      [[ "$2" = +([[:digit:]]) ]] && { sq="$2" ; shift ; }
      ;;
   esac
 done
Dilna
  • 405
  • 1
  • 6