Skip to content

Commit

Permalink
Added !, < and > to SPECIAL_CHARS_UNIX (fixes #99).
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Partington committed Feb 21, 2014
1 parent 1893567 commit 1ff17b1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/xebialabs/overthere/CmdLineArgument.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ public abstract class CmdLineArgument implements Serializable {
/**
* String containing special characters that require quoting or escaping on Unix.
*/
private static final String SPECIAL_CHARS_UNIX = " '\"\\;&|()${}*?";
public static final String SPECIAL_CHARS_UNIX = " '\"\\;&|()${}*?!<>";

/**
* String containing special characters that require quoting or escaping on Windows.
*/
private static final String SPECIAL_CHARS_WINDOWS = " '\";&|()${}*?";
public static final String SPECIAL_CHARS_WINDOWS = " '\";&|()${}*?";

/**
* String used to encode an empty argument as a string.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import static com.google.common.io.ByteStreams.readFully;
import static com.google.common.io.ByteStreams.write;
import static com.google.common.io.Closeables.closeQuietly;
import static com.xebialabs.overthere.CmdLineArgument.SPECIAL_CHARS_UNIX;
import static com.xebialabs.overthere.ConnectionOptions.OPERATING_SYSTEM;
import static com.xebialabs.overthere.ConnectionOptions.PASSWORD;
import static com.xebialabs.overthere.ConnectionOptions.USERNAME;
Expand Down Expand Up @@ -221,6 +222,22 @@ public void shouldExecuteSimpleCommandOnUnix() {
}
}

@Test
@Assumption(methods = "onUnix")
public void shouldExecuteCommandWithSpecialCharactersOnUnix() {
CapturingOverthereExecutionOutputHandler captured = capturingHandler();
int res = connection.execute(multiHandler(sysoutHandler(), captured), syserrHandler(), CmdLine.build("echo", SPECIAL_CHARS_UNIX));
assertThat(res, equalTo(0));
if (captured.getOutputLines().size() == 2) {
// When using ssh_interactive_sudo, the first line may contain a password prompt.
assertThat(captured.getOutputLines().get(0), containsString("assword"));
assertThat(captured.getOutputLines().get(1), containsString(SPECIAL_CHARS_UNIX));
} else {
assertThat(captured.getOutputLines().size(), equalTo(1));
assertThat(captured.getOutput(), containsString(SPECIAL_CHARS_UNIX));
}
}

@Test
@Assumption(methods = "onUnix")
public void shouldExecuteSimpleCommandInWorkingDirectoryOnUnix() {
Expand Down

0 comments on commit 1ff17b1

Please sign in to comment.