From 70c16dd30d4cf824aa895e9f6c095fec741c65a8 Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Mon, 6 Oct 2014 21:51:26 +0800 Subject: [BUILTIN] Return without arguments in a trap should use status outside traps POSIX now requires that return without arguments in a trap should return the last command status prior to executing traps. This patch implements this behaviour. Incidentally this also changes the behaviour of return without arguments in a loop conditional to use the last exit status in the body as opposed to the last command in the conditional when there is one. Signed-off-by: Herbert Xu --- src/trap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/trap.c') diff --git a/src/trap.c b/src/trap.c index 15faeff..b924661 100644 --- a/src/trap.c +++ b/src/trap.c @@ -343,7 +343,8 @@ void dotrap(void) if (!p) continue; evalstring(p, 0); - exitstatus = status; + if (evalskip != SKIPFUNC) + exitstatus = status; } savestatus = last_status; -- cgit 1.4.1