views:

22

answers:

1

I have a variable in my shell script that needs to declared as follows:

MY_VAR="/path/to/exec -options < inputfile"

This is the standard way the executable takes the input. Now, if I do $MY_VAR, the program quits with an error too many arguments. I suspect it is the < sign that is causing the problem. Any way I can get a workaround without splitting the statement into two variables?

Thanks

+1  A: 

You could use eval, but that is considered harmful (see BashFAQ). Try to find a better solution that does not need the whole command line in a variable. For example, use a function:

my_func() {
  /path/to/exec -options < inputFile
}
Philipp
Thanks Philipp. I ended up having to split the MY_VAR and make it into two variables. The command line is part of the options specified by the user. The "<" was a special case.
AK