Issue 126: findPid on windows now matches on window title. fixed error where script exit quit the calling shell in windows

git-svn-id: http://jclouds.googlecode.com/svn/trunk@2354 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-12-01 00:14:28 +00:00
parent e62fe3f6e4
commit 4b24b990be
10 changed files with 10 additions and 11 deletions

View File

@ -55,8 +55,7 @@ public class Call implements Statement {
public String render(OsFamily family) {
StringBuilder args = new StringBuilder();
for (String arg : this.args) {
args.append(String.format(" \"%s\"", Utils.replaceTokens(arg, ShellToken
.tokenValueMap(family))));
args.append(" ").append(Utils.replaceTokens(arg, ShellToken.tokenValueMap(family)));
}
StringBuilder call = new StringBuilder();
call.append(Utils.replaceTokens(OS_TO_CALL.get(family), ImmutableMap.of("function", function,

View File

@ -149,7 +149,7 @@ public enum ShellToken {
case END_SCRIPT:
switch (family) {
case WINDOWS:
return "exit 0\r\n";
return "exit /b 0\r\n";
case UNIX:
return "exit 0\n";
}
@ -170,7 +170,7 @@ public enum ShellToken {
case EXIT:
switch (family) {
case WINDOWS:
return "exit";
return "exit /b";
case UNIX:
return "exit";
}

View File

@ -215,8 +215,8 @@ public class Utils {
}
public static final Map<OsFamily, String> OS_TO_ZERO_PATH = ImmutableMap.of(OsFamily.WINDOWS,
"set PATH=c:\\windows\\;C:\\windows\\system32\r\n", OsFamily.UNIX,
"export PATH=/usr/ucb/bin:/bin:/usr/bin:/usr/sbin\n");
"set PATH=c:\\windows\\;C:\\windows\\system32;c:\\windows\\system32\\wbem\r\n",
OsFamily.UNIX, "export PATH=/usr/ucb/bin:/bin:/usr/bin:/usr/sbin\n");
/**
* @return line used to zero out the path of the script such that basic commands such as unix ps

View File

@ -45,12 +45,12 @@ public class CallTest {
public void testCallArgsUNIX() {
Call call = new Call("help", "me", "rhonda");
assertEquals(call.render(OsFamily.UNIX), "help \"me\" \"rhonda\" || return 1\n");
assertEquals(call.render(OsFamily.UNIX), "help me rhonda || return 1\n");
}
public void testCallArgsWINDOWS() {
Call call = new Call("help", "me", "rhonda");
assertEquals(call.render(OsFamily.WINDOWS),
"call :help \"me\" \"rhonda\"\r\nif errorlevel 1 goto abort\r\n");
"call :help me rhonda\r\nif errorlevel 1 goto abort\r\n");
}
}

View File

@ -55,11 +55,11 @@ public class ShellTokenTest {
public void testTokenValueMapWindows() {
Map<String, String> expected = new ImmutableMap.Builder<String, String>().put("fs", "\\")
.put("ps", ";").put("lf", "\r\n").put("sh", "cmd").put("source", "@call").put("rem",
"@rem").put("args", "%*").put("varl", "%").put("exit", "exit").put("varr",
"@rem").put("args", "%*").put("varl", "%").put("exit", "exit /b").put("varr",
"%").put("libraryPathVariable", "PATH").put("return", "exit /b").put("vq",
"").put("beginFunctions", "GOTO FUNCTION_END\r\n").put("endFunctions",
":FUNCTION_END\r\n").put("beginScript", "@echo off\r\n").put("endScript",
"exit 0\r\n").put("fncl", ":").put("fncr", "\r\n").put("fnce",
"exit /b 0\r\n").put("fncl", ":").put("fncr", "\r\n").put("fnce",
" exit /b 0\r\n").put("export", "set").build();
assertEquals(ShellToken.tokenValueMap(OsFamily.WINDOWS), expected);

View File

@ -23,6 +23,6 @@ function findPid {
}
}
export PATH=/usr/ucb/bin:/bin:/usr/bin:/usr/sbin
findPid "$@" || exit 1
findPid $@ || exit 1
echo $FOUND_PID
exit 0