Unlike reported here, getopt does not die when it gets an unknown option but
continues parsing:

$ getopt -o abc -- -a -f -b -g -c
getopt: invalid option -- 'f'
getopt: invalid option -- 'g'
 -a -b -c --

You can use the -q option to surpress the error messages.

That being said, you can use a '--' argument to separate options:

$ getopt -o abc -- -a -f -- -b -g -c
 -a -- '-b' '-g' '-c'

Ie. everything after a '--' does not get parsed and could be sent to another
script.

An example of this:

  # Invoke as wrapper [WRAPPEROPTION]... -- ORIGINALARGS...
  # Wrapper options are here -a and -b, just to demonstrate
  # Example: wrapper -a -- --orig option -here -a
  # This calls: original_program --orig option -here -a

  TEMP=`getopt -o ab -n 'wrapper' -- "$@"`
  if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
  eval set -- "$TEMP"
  while true ; do
    case "$1" in
      -a) echo "Handling -a in the wrapper"; shift ;;
      -b) echo "Handling -b in the wrapper"; shift ;;
      --) shift; break;;
      *) echo "Internal error!" ; exit 1 ;;
    esac
  done
  original_program "$@"

Regards,
  Frodo

-- 
Frodo Looijaard <fr...@frodo.looijaard.name> (See http://frodo.looijaard.name/)
Defenestration n. (formal or joc.):
  The act of removing Windows from your computer in disgust, usually followed
  by the installation of Linux or some other Unix-like operating system.


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to