I have a bash script that normally works like this:
[...]
file=$1
docommand $x $y $file $z
but I'd like to add an option to the script that would tell it to get the data from a command using an anonymous named pipe instead of the file. I.e., I'd like to do something approximating
file=<(anothercmd arg1 $1 arg3)
and have my
docommand $x $y $file $z
expand to
docommand $x $y <(anothercmd arg1 $1 arg3) $z
Is there a way to get the quoting right to accomplish that?
For more concrete context, the script looks at output products from regression tests, normally diffing them from a file with the expected output. I'd like to optionally pass in a revision and diff to the then-expected result, so diff $from $to
would expand to diff <(hg cat -r $fromrev $from) $to
.
Use eval:
example