I have a shell script that accepts a variety of options, some with arguments, some without, some short, some long. It should handle some of these options itself and pass on the rest it does not know how to care about to another program. Can I get getopts or something along its lines to store away unknown arguments?
So for example, say my script is called program and should accept arguments
-nwith a single argument,--verbosewithout any argument and-swithout any argument.
It parses and prints all its options and their arguments and then calls echo rest: with anything that remains. The following output should be observed.
> program -sin42 --long --verbose
-s
-n with argument 42
--verbose
rest: -i --long
> program -n --short
-n with argument --short
> program -n
error: -n without argument
Can something like this be achieved in a shell script?