From 4db3447eedb1e362376b9a09d8a903c55bef0b14 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Wed, 14 Oct 2009 11:45:56 +0300 Subject: [PATCH] Ticket #213 [mc-ru-fork] patch for fix bug 'The shell is already running a command' Test case: - run mc - press CTRL+o (hide panels) - press 'space' key - press 'backspace' key - press CTRL+o (show panels) - type 'ls' and press 'enter' key Fix issue: Now 'busy shell' status toggle on if user will press 'Enter' key. Old behavior: User was press any key into subshell and 'busy shell' status toggle on. Also, patch will enter new behavior: * run mc * press ctrl+o (hide panels) * type 'cat ' and don't press 'Enter' key * press ctrl+o (show panels) * type 'ls' and press enter You'll see: cat: ls: File not found. Signed-off-by: Slava Zanko --- src/subshell.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/subshell.c b/src/subshell.c index 1e33996f2..e4883b270 100644 --- a/src/subshell.c +++ b/src/subshell.c @@ -573,7 +573,8 @@ int invoke_subshell (const char *command, int how, char **new_dir) subshell_state = ACTIVE; /* FIXME: possibly take out this hack; the user can re-play it by hitting C-hyphen a few times! */ - write_all (subshell_pty, " \b", 2); /* Hack to make prompt reappear */ + if (subshell_ready) + write_all (subshell_pty, " \b", 2); /* Hack to make prompt reappear */ } } else /* MC has passed us a user command */ @@ -1052,7 +1053,9 @@ feed_subshell (int how, int fail_on_error) } write_all (subshell_pty, pty_buffer, bytes); - subshell_ready = FALSE; + + if (pty_buffer[bytes-1] == '\n' || pty_buffer[bytes-1] == '\r') + subshell_ready = FALSE; } else { return FALSE; }