1

I have a bash script running on MacOS (Bash 3.2.57). The script takes arguments, and the arguments can have spaces. I would like to store the arguments in a variable and then call an executable. I can do this using eval:

arg="'file a' 'file b' '${1}'"
eval find ${arg}

And the result of ./test.sh is:

file a
file b
file c

Are there any alternatives to using eval as I've read that I should avoid eval. When I try to replace with exec, I get the arguments split by space, when I set IFS='', I get one long argument. I can't seem to find the optimal solution.

iruvar
  • 16,725
nachum
  • 111

0 Answers0