Today I had to add a task to an Apache Ant file. The command line should have been something like
myprogram --param1 --param2 path\somefile 2> path\logfile
The problem with this was that if I used something like the following for this
<exec executable="$(myprogram)"
<arg value="--param1">
<arg value="--param2">
<arg path="$(somefile)">
<arg value="2>">
<arg path="$(logfile)">
</exec>
all arguments were quoted, so the command looked like this:
myprogram "--param1" "--param2" "path\somefile" "2>" "path\logfile"
which is not bad and especially nice if you have spaces in your files/path, but destroys the pipe to the logfile (instead, the program thinks there are two additional file arguments "2>" and "path\logfile").
I worked around this by calling a batch script instead that only wants the files as parameters, but I wondered: Is it possible to do this without such a workaround?