From e3df11cc0a969652c9b14c117a62e86c22f8a0ce Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Thu, 14 Aug 2003 16:16:21 +0000 Subject: [PATCH] Avoid "useless use of cat" award by using a real world example. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275094 13f79535-47bb-0310-9956-ffa450edef68 --- docs/faq.html | 19 ++++++++++--------- xdocs/faq.xml | 19 ++++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/docs/faq.html b/docs/faq.html index f2eb13f26..ee57b2c12 100644 --- a/docs/faq.html +++ b/docs/faq.html @@ -673,26 +673,27 @@ How do I redirect standard input or standard output in the <exec> task?

-

Say you want to redirect the standard input stream of the - cat command to read from a file, something +

Say you want to redirect the standard output stream of the + m4 command to write to a file, something like:

-shell-prompt> cat < foo
+shell-prompt> m4 foo.m4 > foo
 

and try to translate it into

-<exec executable="cat">
-  <arg value="&lt;" />
-  <arg value="foo" />
+<exec executable="m4">
+  <arg value="foo.m4"/>
+  <arg value="&gt;"/>
+  <arg value="foo"/>
 </exec>
 
-

This will not do what you expect. The input redirection is +

This will not do what you expect. The output redirection is performed by your shell, not the command itself, so this should read:

 <exec executable="/bin/sh">
   <arg value="-c" />
-  <arg value="cat &lt; foo" />
+  <arg value="m4 foo.m4 &gt; foo" />
 </exec>
 

Note that you must use the value attribute of @@ -701,7 +702,7 @@ shell-prompt> cat < foo you can use:

 <exec executable="/bin/sh">
-  <arg line='-c "cat &lt; foo"'/>
+  <arg line='-c "m4 foo.m4 &gt; foo"'/>
 </exec>
 

Note the double-quotes nested inside the single-quotes.

diff --git a/xdocs/faq.xml b/xdocs/faq.xml index 71d950fb5..bc15465f9 100644 --- a/xdocs/faq.xml +++ b/xdocs/faq.xml @@ -313,31 +313,32 @@ How do I redirect standard input or standard output in the <exec> task? -

Say you want to redirect the standard input stream of the - cat command to read from a file, something +

Say you want to redirect the standard output stream of the + m4 command to write to a file, something like:

cat < foo +shell-prompt> m4 foo.m4 > foo ]]>

and try to translate it into

- - + + + + ]]> -

This will not do what you expect. The input redirection is +

This will not do what you expect. The output redirection is performed by your shell, not the command itself, so this should read:

- + ]]> @@ -347,7 +348,7 @@ shell-prompt> cat < foo you can use:

- + ]]>