Background
I have a program prog
that takes input from stdin and does something to it. It also takes a flag -f FILE
to find a datafile used during operation.
I wish to create a bash script to act as a wrapper around this program so that this flag need not be used. So I wrote the following script progwrap.sh
:
#!/bin/bash
/path/to/prog -f /path/to/data
which does the trick for basic functionality, so that I can do something like
$ cat somedata.txt | progwrap.sh
and get what I want.
Goal
Now, it turns out that prog
also takes some other flags of the form -h
, -u
, etc... I want to be able to pass these to progwrap.sh
so that they are in turned passed to prog
. So I amended progwrap.sh
as follows:
#!/bin/bash
/path/to/prog -f /path/to/data "$@"
allowing it to take arguments and supposedly feeding them to prog
within the script.
Problem
However this somehow doesn't work, in that:
$ cat somedata.txt | progwrap.sh -h
produces the exact same output as
$ cat somedata.txt | progwrap.sh
which is not the correct behaviour (i.e. the output should come out in a different format as a result of the -h flag being passed to progwrap.sh).
In fact, feeding progwrap
nonsense arguments for which prog
has no support, and which usually cause prog
to throw an error, does nothing. I conclude that the arguments passed to progwrap.sh
are ignored by the call to prog
within the script.
Question
What am I doing wrong? How can I pass flags to progwrap.sh
so that these flags are then passed to prog
within my script?