Browse Source

make Execute support Windows XP.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271003 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
487989a059
1 changed files with 18 additions and 12 deletions
  1. +18
    -12
      src/main/org/apache/tools/ant/taskdefs/Execute.java

+ 18
- 12
src/main/org/apache/tools/ant/taskdefs/Execute.java View File

@@ -1,7 +1,7 @@
/* /*
* The Apache Software License, Version 1.1 * The Apache Software License, Version 1.1
* *
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights
* reserved. * reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -76,6 +76,8 @@ import java.util.Vector;
* Runs an external program. * Runs an external program.
* *
* @author thomas.haas@softwired-inc.com * @author thomas.haas@softwired-inc.com
*
* @version $Revision$
*/ */
public class Execute { public class Execute {


@@ -135,12 +137,14 @@ public class Execute {
baseLauncher = new CommandLauncher(); baseLauncher = new CommandLauncher();
} }


// Determine if we're running under 2000/NT or 98/95
// Determine if we're running under XP/2000/NT or 98/95
String osname = String osname =
System.getProperty("os.name").toLowerCase(Locale.US); System.getProperty("os.name").toLowerCase(Locale.US);


if ( osname.indexOf("nt") >= 0 || osname.indexOf("2000") >= 0 ) {
// Windows 2000/NT
if ( osname.indexOf("nt") >= 0 ||
osname.indexOf("2000") >= 0 ||
osname.indexOf("xp") >= 0 ) {
// Windows XP/2000/NT
shellLauncher = new WinNTCommandLauncher(baseLauncher); shellLauncher = new WinNTCommandLauncher(baseLauncher);
} }
else { else {
@@ -173,7 +177,7 @@ public class Execute {
*/ */
public static synchronized Vector getProcEnvironment() { public static synchronized Vector getProcEnvironment() {
if (procEnvironment != null) { if (procEnvironment != null) {
return procEnvironment;
return procEnvironment;
} }


procEnvironment = new Vector(); procEnvironment = new Vector();
@@ -231,9 +235,11 @@ public class Execute {
else if ( Os.isFamily("windows") ) { else if ( Os.isFamily("windows") ) {
String osname = String osname =
System.getProperty("os.name").toLowerCase(Locale.US); System.getProperty("os.name").toLowerCase(Locale.US);
// Determine if we're running under 2000/NT or 98/95
if ( osname.indexOf("nt") >= 0 || osname.indexOf("2000") >= 0 ) {
// Windows 2000/NT
// Determine if we're running under XP/2000/NT or 98/95
if ( osname.indexOf("nt") >= 0 ||
osname.indexOf("2000") >= 0 ||
osname.indexOf("xp") >= 0 ) {
// Windows XP/2000/NT
String[] cmd = {"cmd", "/c", "set" }; String[] cmd = {"cmd", "/c", "set" };
return cmd; return cmd;
} }
@@ -329,7 +335,7 @@ public class Execute {
*/ */
public String[] getEnvironment() { public String[] getEnvironment() {
if (env == null || newEnvironment) { if (env == null || newEnvironment) {
return env;
return env;
} }
return patchEnvironment(); return patchEnvironment();
} }
@@ -414,7 +420,7 @@ public class Execute {
processDestroyer.add(process); processDestroyer.add(process);


if (watchdog != null) { if (watchdog != null) {
watchdog.start(process);
watchdog.start(process);
} }
waitFor(process); waitFor(process);


@@ -423,11 +429,11 @@ public class Execute {
processDestroyer.remove(process); processDestroyer.remove(process);


if (watchdog != null) { if (watchdog != null) {
watchdog.stop();
watchdog.stop();
} }
streamHandler.stop(); streamHandler.stop();
if (watchdog != null) { if (watchdog != null) {
watchdog.checkException();
watchdog.checkException();
} }
return getExitValue(); return getExitValue();
} }


Loading…
Cancel
Save