views:

132

answers:

1

i am writing a bash script which acts as a wrapper around another command. it needs to be able to understand all of the parameters the command understands, plus a few extra. for example, if the command understands -abc switches and i wish for my wrapper script to understand those plus a -d and -e switch, then i need a way to look for and remove the -d and -e switches, and then to pass-on the remaining parameters to the command.

i know there is probably some way to do this using getopts or getopt plus $*/$@, but I am not sure how. also, the command that i need to invoke takes a few long options (like --help) in addition to switches. i don't need for my wrapper script to take long options of its own, just to pass along to the command all parameters (including long ones) except for the few additional switches only my script understands.

thank you for any help in advance

A: 

Probably the most straightforward thing to do is to just build up a 2nd set of arguments to be passed to your other command. The arg parser for the script you're writing will consume the options that it understands and add the rest to a shell variable which ends up getting used as the args for the other command.

Chris Cleeland