I'm trying to write a wrapper script around another program (e.g. foo_wrapper
around foo
), which simply overrides some flags on every call to foo
. I want users to be able to interact with foo_wrapper
and foo
exactly the same way, including seeing the same bash completion output.
For example, foo_wrapper.sh
should simply add --my_flag
on every call to foo
, but it's not enough to simply prepend or append flags to the argument list, it has to put them in the right location because of the way foo
is implemented. So if the user calls foo_wrapper bar baz
, I want it to map to foo bar --my_flag baz
. This is why I assume I cannot simply use a bash alias.
This would be a simple script if I didn't need bash completion to work, but without bash completion this thing is not going to be nearly as useful. Can anyone help me figure out what to do here? I discovered the compgen
builtin for bash, but I'm having trouble seeing how/if I can use it for this.