From 1e7fc8422c00e8ed69ccd844e27c498f798c284f Mon Sep 17 00:00:00 2001 From: Jussi Maki Date: Tue, 26 May 2026 10:59:31 +0200 Subject: [PATCH] shell: Fix error handling in interactive shell interactiveShell() did not check for the <> marker which caused it to wait for more input instead of returning to the prompt: example> aoeu :0: aoeu unknown command<> Fix this by checking for <> and treating it as an end marker in interactive shell. Signed-off-by: Jussi Maki --- shell/client.go | 3 ++- shell/shell_test.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/shell/client.go b/shell/client.go index 5fd0849..f5e4136 100644 --- a/shell/client.go +++ b/shell/client.go @@ -235,12 +235,13 @@ repl: } line, ended := strings.CutSuffix(line, endMarker) + line, errored := strings.CutSuffix(line, errorMarker) if isPrefix { fmt.Fprint(console, line) } else { fmt.Fprintln(console, line) } - if ended { + if ended || errored { break } } diff --git a/shell/shell_test.go b/shell/shell_test.go index 8d5cb30..c070302 100644 --- a/shell/shell_test.go +++ b/shell/shell_test.go @@ -93,10 +93,11 @@ func TestInteractiveShell(t *testing.T) { // Interactive use cmd := exec.Command(os.Args[0], "-client", sock) - cmd.Stdin = strings.NewReader("help help\r\nexit\r\n") + cmd.Stdin = strings.NewReader("unknown\r\nhelp help\r\nexit\r\n") out, err := cmd.CombinedOutput() require.NoError(t, err, "CombinedOutput") + require.Contains(t, string(out), "unknown: unknown command") require.Contains(t, string(out), "test> help help") require.Contains(t, string(out), "log help text")