From 297b780dc8a50d9091b68bbd1d8a974a6488d43c Mon Sep 17 00:00:00 2001 From: Karsten Blees Date: Fri, 8 May 2015 23:40:29 +0200 Subject: [PATCH] fixup! mingw: Support `git_terminal_prompt` with more terminals Reduce shell invocations by chaining commands together. Use 'echo' instead of 'printf \\n'. Use 'read -s' instead of 'stty [-]echo', because we don't have 'stty' in old msysgit. Use 'bash' instead of 'sh' as 'read -s' is bash-specific (in case we ever switch to dash or some other POSIX-only shell). Signed-off-by: Karsten Blees --- compat/terminal.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/compat/terminal.c b/compat/terminal.c index 025960d80e..4081eafa1b 100644 --- a/compat/terminal.c +++ b/compat/terminal.c @@ -97,20 +97,16 @@ static int disable_echo(void) static char *xterm_prompt(const char *prompt, int echo) { const char *read_input[] = { - "sh", "-c", - "cat >/dev/tty && read -r line /dev/tty && read -r line /dev/tty && read -r -s line /dev/tty", NULL }; - const char *echo_off[] = { "sh", "-c", "stty -echo /dev/tty", NULL }; struct child_process child = CHILD_PROCESS_INIT; static struct strbuf buffer = STRBUF_INIT; int prompt_len = strlen(prompt), len = -1, code; - if (!echo && run_command_v_opt(echo_off, 0)) - warning("Could not disable echo on xterm"); - child.argv = read_input; child.in = -1; child.out = -1; @@ -143,12 +139,6 @@ ret: if (!code) finish_command(&child); - if (!echo) { - if (run_command_v_opt(echo_on, 0)) - warning("Could not enable echo on xterm"); - run_command_v_opt(new_line, 0); - } - return len < 0 ? NULL : buffer.buf; }