Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,11 @@ public void run() {
}
}
// send command to server
outputStream.write((command + " | plaintext\n").getBytes(StandardCharsets.UTF_8));
String commandWithPlaintext = command.replaceFirst("\\s*&\\s*$", " | plaintext &");
if (commandWithPlaintext.equals(command)) {
commandWithPlaintext += " | plaintext";
}
outputStream.write((commandWithPlaintext + "\n").getBytes(StandardCharsets.UTF_8));
outputStream.flush();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,31 @@ void quietBatchModeShouldSendCommandWhenPromptStartsTheStream() throws Exception
}
}

@Test
void batchModeShouldKeepBackgroundMarkerAfterPlaintextPipeline() throws Exception {
ExecutorService executorService = Executors.newSingleThreadExecutor();
try (ServerSocket serverSocket = new ServerSocket(0)) {
Future<ServerResult> serverResult = executorService.submit(() -> runPromptFirstServer(serverSocket));

int status = TelnetConsole.process(new String[] {
"--quiet",
"-c",
"version &",
"-t",
"1000",
"127.0.0.1",
String.valueOf(serverSocket.getLocalPort())
});

ServerResult result = serverResult.get(2, TimeUnit.SECONDS);
assertThat(status).isEqualTo(TelnetConsole.STATUS_OK);
assertThat(result.command).contains("version | plaintext &");
assertThat(result.quit).isEqualTo("quit");
} finally {
executorService.shutdownNow();
}
}

@Test
void batchModeShouldNegotiateBinaryAndSendChineseCommandAsUtf8() throws Exception {
ExecutorService executorService = Executors.newSingleThreadExecutor();
Expand Down