-> As an interim measure, it would probably be easier if the 
-> <exec> could detect the use of redirection (|<>) and prepend
-> the command with either "cmd /c" or "sh", depending on environment...

Thanks Troy!  That's a nice tip, and much cleaner than
what I was previously doing (intermediary scripts).

Implementation was a little trickier than it first looked,
especially when you have variable input, due to the way
CMD treats the /C switch (details are in CMD /?)

One approach is to use the /S switch and always place
quotes at the beginning and ending of a command line,
which get stripped, but leave any other quotes intact.

Here's a convoluted example:

<target name="execute" depends="init-windows,init-linux">
    <exec program="${shell}">
        <arg line='${start}"${program}" ${params} &lt; "${input}"${end}'/>
    </exec>
</target>

<target name="init-windows" if="${platform::is-win32()}">
    <property name="shell" value="CMD"/>
    <property name="start" value='/S /C " '/>
    <property name="end"   value=' "'/>
</target>

<target name="init-linux" if="${platform::is-unix()}">
    <property name="shell" value="sh"/>
    <property name="start" value=""/>
    <property name="end"   value=""/>
</target>

Caveat: I haven't test this on Linux yet (waiting
for Mono on Linux to be more NAnt friendly) but it
worked on .Net and Mono on Windows

peace
si


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Nant-users mailing list
Nant-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to