[git commit] ash: follow bash in allowing multiple !s: "! ! CMD" is the same as "CMD"

Denys Vlasenko vda.linux at googlemail.com
Fri Oct 9 11:36:11 UTC 2026


commit: https://git.busybox.net/busybox/commit/?id=a040aa28269152483d546b4a0fe165de4474eeec
branch: https://git.busybox.net/busybox/log/?h=master

function                                             old     new   delta
pipeline                                             167     165      -2

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 shell/ash.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/shell/ash.c b/shell/ash.c
index 88c16487f..c35c53d37 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -12623,11 +12623,13 @@ pipeline(void)
 
 	negate = 0;
 	TRACE(("pipeline: entered\n"));
-	if (readtoken() == TNOT) {
+	/* At least bash 5.2.15 allows multiple negations */
+	/* "! ! CMD" does not mean "normalize to only 0 or 1", it just nullifies first ! */
+	while (readtoken() == TNOT) {
 		negate = !negate;
-		checkkwd = CHKKWD | CHKALIAS;
-	} else
-		tokpushback = 1;
+		checkkwd = CHKKWD | CHKALIAS; /* restore what readtoken() cleared */
+	}
+	tokpushback = 1;
 	n1 = parse_command();
 	if (readtoken() == TPIPE) {
 		pipenode = stzalloc(sizeof(struct npipe));
@@ -14011,13 +14013,10 @@ readtoken(void)
 	int t;
 	int kwd = checkkwd;
 #if DEBUG
-	smallint alreadyseen = tokpushback;
-#endif
-
-#if ENABLE_ASH_ALIAS
- top:
+	int alreadyseen = tokpushback;
 #endif
 
+ IF_ASH_ALIAS(top:)
 	t = xxreadtoken();
 
 	/*


More information about the busybox-cvs mailing list