I noticed that when you use <exec> on JDK 1.3 and specify a working
directory, and that directory happens to be the same as the Ant VM's own
current working directory, the resultant process is messed up and has no
defined working directory (numerous errors in shell scripts and so on).

The working dir argument can be null if it would otherwise be unchanged
from the current working dir. In the current implementation it seems to
pass along that null as cwd (and Java happily lets you). Here is a patch
which ought to solve it. It is UNTESTED, hopefully the author of <exec>
can evaluate whether it makes sense.

-Jesse

-- 
Jesse Glick   <mailto:[EMAIL PROTECTED]>
NetBeans, Open APIs  <http://www.netbeans.org/>
tel (+4202) 3300-9161 Sun Micro x49161 Praha CR
Index: src/main/org/apache/tools/ant/taskdefs/Execute.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Execute.java,v
retrieving revision 1.12
diff -u -r1.12 Execute.java
--- src/main/org/apache/tools/ant/taskdefs/Execute.java 2001/01/12 14:08:50     
1.12
+++ src/main/org/apache/tools/ant/taskdefs/Execute.java 2001/02/12 19:42:22
@@ -492,6 +492,10 @@
         public Process exec(Project project, String[] cmd, String[] env, File 
workingDir) 
             throws IOException
         {
+            if (workingDir == null) {
+                return Runtime.getRuntime().exec(cmd, env);
+            }
+
             try {
                 Object[] arguments = { cmd, env, workingDir };
                 return (Process)_execWithCWD.invoke(Runtime.getRuntime(), 
arguments);

Reply via email to