From 0b1e459d5ce8a519a6419a713c57693c68d4a6d2 Mon Sep 17 00:00:00 2001
From: Stefan Bodewig
Date: Wed, 31 Oct 2001 11:02:23 +0000
Subject: [PATCH] Add OS/2 as Os family
git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269846 13f79535-47bb-0310-9956-ffa450edef68
---
docs/manual/CoreTasks/condition.html | 3 ++-
.../apache/tools/ant/taskdefs/condition/Os.java | 15 +++++++++++++--
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/docs/manual/CoreTasks/condition.html b/docs/manual/CoreTasks/condition.html
index c877e9b60..e65999971 100644
--- a/docs/manual/CoreTasks/condition.html
+++ b/docs/manual/CoreTasks/condition.html
@@ -99,7 +99,8 @@ are redundant and will be ignored.
Microsoft Windows and OS/2)
mac (for all Apple Macintosh systems)
unix (for all Unix and Unix-like operating systems)
- netware
+ netware (for Novell Netware)
+ os/2 (for OS/2)
equals
diff --git a/src/main/org/apache/tools/ant/taskdefs/condition/Os.java b/src/main/org/apache/tools/ant/taskdefs/condition/Os.java
index f8feeb16e..8023d424f 100644
--- a/src/main/org/apache/tools/ant/taskdefs/condition/Os.java
+++ b/src/main/org/apache/tools/ant/taskdefs/condition/Os.java
@@ -56,6 +56,8 @@ package org.apache.tools.ant.taskdefs.condition;
import org.apache.tools.ant.BuildException;
+import java.util.Locale;
+
/**
* Condition that tests the OS type.
*
@@ -65,6 +67,12 @@ import org.apache.tools.ant.BuildException;
public class Os implements Condition {
private String family;
+ public Os() {}
+
+ public Os(String family) {
+ setFamily(family);
+ }
+
/**
* Sets the desired OS family type
*
@@ -73,10 +81,11 @@ public class Os implements Condition {
* - dos
* - mac
* - netware
+ * - os/2
* - unix
* - windows
*/
- public void setFamily(String f) {family = f.toLowerCase();}
+ public void setFamily(String f) {family = f.toLowerCase(Locale.US);}
/**
* Determines if the OS on which Ant is executing matches the type of
@@ -84,11 +93,13 @@ public class Os implements Condition {
* @see Os#setFamily(String)
*/
public boolean eval() throws BuildException {
- String osName = System.getProperty("os.name").toLowerCase();
+ String osName = System.getProperty("os.name").toLowerCase(Locale.US);
String pathSep = System.getProperty("path.separator");
if (family != null) {
if (family.equals("windows")) {
return osName.indexOf("windows") > -1;
+ } else if (family.equals("os/2")) {
+ return osName.indexOf("os/2") > -1;
} else if (family.equals("netware")) {
return osName.indexOf("netware") > -1;
} else if (family.equals("dos")) {