Wenn PROMPT_COMMAND is used then a "echo $?" shows the result of the PROMPT_COMMAND instead of the result of the last command. Fix this by restoring the previous value after PROMPT_COMMAND has been executed.
Signed-off-by: Sascha Hauer <[email protected]> --- common/hush.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/hush.c b/common/hush.c index 8515e77338..ec3c0cd913 100644 --- a/common/hush.c +++ b/common/hush.c @@ -433,9 +433,13 @@ static char *getprompt(void) prompt_command = getenv("PROMPT_COMMAND"); if (prompt_command) { + unsigned int lr = last_return_code; + initialize_context(&ctx); parse_string_outer(&ctx, prompt_command, FLAG_PARSE_SEMICOLON); release_context(&ctx); + + last_return_code = lr; } ps1 = getenv("PS1"); -- 2.47.3
