commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r647217 - in /commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec: CommandLine.java launcher/VmsCommandLauncher.java
Date Fri, 11 Apr 2008 16:37:17 GMT
Author: sebb
Date: Fri Apr 11 09:37:11 2008
New Revision: 647217

URL: http://svn.apache.org/viewvc?rev=647217&view=rev
Log:
Fix nested VMS script handling (hopefully)

Modified:
    commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java
    commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec/launcher/VmsCommandLauncher.java

Modified: commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java
URL: http://svn.apache.org/viewvc/commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java?rev=647217&r1=647216&r2=647217&view=diff
==============================================================================
--- commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java (original)
+++ commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java Fri
Apr 11 09:37:11 2008
@@ -51,6 +51,8 @@
      */
     private Map substitutionMap;
 
+    private final boolean isFile;
+
     /**
      * Create a command line from a string.
      * 
@@ -99,6 +101,7 @@
      * @param executable the executable
      */
     public CommandLine(String executable) {
+        this.isFile=false;
         setExecutable(executable);
     }
 
@@ -108,6 +111,7 @@
      * @param  executable the executable 
      */
     public CommandLine(File executable) {
+        this.isFile=true;
         setExecutable(executable.getAbsolutePath());
     }
 
@@ -118,6 +122,10 @@
      */
     public String getExecutable() {
         return this.expandArgument(executable);
+    }
+
+    public boolean isFile(){
+        return isFile;
     }
 
     /**

Modified: commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec/launcher/VmsCommandLauncher.java
URL: http://svn.apache.org/viewvc/commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec/launcher/VmsCommandLauncher.java?rev=647217&r1=647216&r2=647217&view=diff
==============================================================================
--- commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec/launcher/VmsCommandLauncher.java
(original)
+++ commons/sandbox/exec/trunk/src/main/java/org/apache/commons/exec/launcher/VmsCommandLauncher.java
Fri Apr 11 09:37:11 2008
@@ -28,6 +28,7 @@
 import java.util.Set;
 
 import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.util.StringUtils;
 
 /**
  * A command launcher for VMS that writes the command to a temporary DCL script
@@ -89,7 +90,25 @@
                 }
             }
 
-            out.print("$ " + cmd.getExecutable());
+            final String command = cmd.getExecutable();
+            if (cmd.isFile()){// We assume it is it a script file
+                out.print("$ @");
+                // This is a bit crude, but seems to work
+                String parts[] = StringUtils.split(command,"/");
+                out.print(parts[0]); // device
+                out.print(":[");
+                out.print(parts[1]); // top level directory
+                final int lastPart = parts.length-1;
+                for(int i=2; i< lastPart; i++){
+                    out.print(".");
+                    out.print(parts[i]);
+                }
+                out.print("]");
+                out.print(parts[lastPart]);
+            } else {
+                out.print("$ ");
+                out.print(command);                
+            }
             String[] args = cmd.getArguments();
             for (int i = 0; i < args.length; i++) {
                 out.println(" -");



Mime
View raw message