Paul Cantrell wrote:
I double-checked what Stefan said; he is indeed correct. The following
is on OS X 10.2.1:
$ ant -version
Apache Ant version 1.5 compiled on July 9 2002
$ bsh -cp /usr/local/java/jakarta/jakarta-ant/lib/ant.jar
BeanShell 1.2b42 - by Pat Niemeyer
bsh % show();
<true>
bsh % org.apache.tools.ant.taskdefs.condition.Os.isFamily("mac");
<true>
bsh % org.apache.tools.ant.taskdefs.condition.Os.isFamily("unix");
<true>
bsh % System.getProperty("os.name");
<Mac OS X>
I know that's not the most up-to-date version of Ant (or BeanShell, for
that matter), but I doubt that the results have changed.
Paul
What about adding the same for as/400 which is very similar to unix
on it's IFS file system (just to avoid making duplicate checks for
chmod/chgrp/symlinks....)
public static boolean isOs(String family, String name, String arch,
String version) {
boolean retValue = false;
if (family != null || name != null || arch != null
|| version != null) {
boolean isFamily = true;
boolean isName = true;
boolean isArch = true;
boolean isVersion = true;
if (family != null) {
if (family.equals("windows")) {
isFamily = osName.indexOf("windows") > -1;
} else if (family.equals("os/2")) {
isFamily = osName.indexOf("os/2") > -1;
} else if (family.equals("netware")) {
isFamily = osName.indexOf("netware") > -1;
} else if (family.equals("dos")) {
isFamily = pathSep.equals(";") && !isFamily("netware");
} else if (family.equals("mac")) {
isFamily = osName.indexOf("mac") > -1;
} else if (family.equals("unix")) {
if (osName.indexOf("mac") > -1)
isFamily = pathSep.equals(":")
&& (!isFamily("mac") ||
osName.endsWith("x"));
else
isFamily = (osName.indexOf("as/400") > -1);
} else if (family.equals("win9x")) {
isFamily = isFamily("windows") &&
!(osName.indexOf("nt") >= 0 ||
osName.indexOf("2000") >= 0 ||
osName.indexOf("xp") >= 0);
} else if (family.equals("z/os")) {
isFamily = osName.indexOf("z/os") > -1
|| osName.indexOf("os/390") > -1;
} else if (family.equals("os/400")) {
isFamily = osName.indexOf("os/400") > -1;
} else {
throw new BuildException(
"Don\'t know how to detect os family \""
+ family + "\"");
}
}
if (name != null) {
isName = name.equals(osName);
}
if (arch != null) {
isArch = arch.equals(osArch);
}
if (version != null) {
isVersion = version.equals(osVersion);
}
retValue = isFamily && isName && isArch && isVersion;
}
return retValue;
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>