ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 16924] New: - <apply> and <exec> do not work
Date Mon, 10 Feb 2003 10:06:43 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16924>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16924

<apply> and <exec> do not work

           Summary: <apply> and <exec> do not work
           Product: Ant
           Version: 1.5.1
          Platform: PC
        OS/Version: OS/2
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Core tasks
        AssignedTo: ant-dev@jakarta.apache.org
        ReportedBy: wagner@cesnet.cz


Tasks <apply> and <exec> do not work in OS/2. The reason is that the "cd"
command does not recognize the "/d" switch an the working directory must be
changed in two steps, first the drive and second the directory. OS/2 does not
allow to use netbios paths in form \\computer\source\some\path, therefore I do
not check it. the problem is in main.org.apache.tools.ant.taskdefs.Execute, my
patch (verified with Revision 1.43.2.5) is below:

--- Execute.java.orig	Wed Oct  2 11:09:02 2002
+++ Execute.java	Thu Feb  6 12:05:10 2003
@@ -714,14 +714,26 @@
 
             // Use cmd.exe to change to the specified directory before running
             // the command
-            final int preCmdLength = 6;
+            int preCmdLength;
+            if (Os.isFamily("os/2")) preCmdLength = 7;
+            else preCmdLength = 6;
             String[] newcmd = new String[cmd.length + preCmdLength];
             newcmd[0] = "cmd";
             newcmd[1] = "/c";
-            newcmd[2] = "cd";
-            newcmd[3] = "/d";
-            newcmd[4] = commandDir.getAbsolutePath();
-            newcmd[5] = "&&";
+            if (preCmdLength == 6) {   // Windows
+                newcmd[2] = "cd";
+                newcmd[3] = "/d";
+                newcmd[4] = commandDir.getAbsolutePath();
+                newcmd[5] = "&&";
+            }
+            else {   // OS/2 does not have /d switch in cd
+                final String cmdDir = commandDir.getAbsolutePath();
+                newcmd[2] = cmdDir.substring(0, 2);
+                newcmd[3] = "&&";
+                newcmd[4] = "cd";
+                newcmd[5] = cmdDir.substring(2);
+                newcmd[6] = "&&";
+            }
             System.arraycopy(cmd, 0, newcmd, preCmdLength, cmd.length);
 
             return exec(project, newcmd, env);

Mime
View raw message