Friday, January 06, 2006

NAnt exec: add quotes to commandline

After posting NAnt exec: arg || commandline, an anonymous reader asked how to add quotes to some arguments and not others.

A simple solution would be to use commandline and delimit the string with single quotes.
<exec program="ruby" commandline='parse_text.rb "some text file.txt"'/>
However, this solution feels like a hack and isn't immediately obvious.

Another (even less obvious) solution is to use &quot;.
<exec program="ruby" commandline="parse_text.rb &quot;some text file.txt&quot;"/>
This doesn't read very well, but it feels less like a hack because you can use a standard double quote delimiter.

Either option you choose isn't very pleasing. Which leads me to reason #1 why I prefer Rake to NAnt.
Post a Comment