mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] hush: fix last_return_code when PROMPT_COMMAND is used
@ 2025-09-17 13:36 Sascha Hauer
  2025-09-18 14:23 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2025-09-17 13:36 UTC (permalink / raw)
  To: Barebox List

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 <s.hauer@pengutronix.de>
---
 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




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-18 14:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-17 13:36 [PATCH] hush: fix last_return_code when PROMPT_COMMAND is used Sascha Hauer
2025-09-18 14:23 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox