From 9e38ab81785c4ac755a7e78d2fe7a7db92bdf375 Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Thu, 6 May 2021 10:03:27 +0100
Subject: 48787: Fix command status after failed if
If "if" had a hard error in the condition, and there was no
else clause, the command status was incorrectly cleared to zero.
Add test.
---
Src/loop.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'Src')
diff --git a/Src/loop.c b/Src/loop.c
index 41b2e5627..aa733a2cb 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -583,7 +583,7 @@ execif(Estate state, int do_exec)
cmdpop();
} else {
noerrexit = olderrexit;
- if (!retflag)
+ if (!retflag && !errflag)
lastval = 0;
}
state->pc = end;
--
cgit 1.4.1