From ad5431d2ca9c4dd454dfb3bc8e9de3ee0ad28a27 Mon Sep 17 00:00:00 2001 From: Jack Palevich Date: Fri, 4 Jun 2010 12:03:14 +0800 Subject: [PATCH] Emit shell prompt even when in non-interactive mode. Change-Id: If85c509efe13e4bdb40216c79d560ea7f83ba813 --- sh/input.c | 3 +++ sh/input.h | 1 + sh/parser.c | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sh/input.c b/sh/input.c index bfb80f469..056ee8b6e 100644 --- a/sh/input.c +++ b/sh/input.c @@ -175,6 +175,9 @@ pgetc(void) return pgetc_macro(); } +int in_interactive_mode() { + return parsefile != NULL && parsefile->fd == 0; +} static int preadfd(void) diff --git a/sh/input.h b/sh/input.h index a9d3a12b4..99c1b77b6 100644 --- a/sh/input.h +++ b/sh/input.h @@ -46,6 +46,7 @@ extern int parsenleft; /* number of characters left in input buffer */ extern char *parsenextc; /* next character in input buffer */ extern int init_editline; /* 0 == not setup, 1 == OK, -1 == failed */ +int in_interactive_mode(); char *pfgets(char *, int); int pgetc(void); int preadbuffer(void); diff --git a/sh/parser.c b/sh/parser.c index d956375e7..faf0268fa 100644 --- a/sh/parser.c +++ b/sh/parser.c @@ -1629,9 +1629,9 @@ setprompt(int which) if (!el) #endif #ifdef WITH_LINENOISE -#else - out2str(getprompt(NULL)); + if (! in_interactive_mode() ) #endif + out2str(getprompt(NULL)); } /*