Module Name:    src
Committed By:   kre
Date:           Mon Dec 25 04:52:38 UTC 2023

Modified Files:
        src/bin/sh: eval.c

Log Message:
PR bin/57773

Fix a bug reported by Jarle Fredrik Greipsland in PR bin/57773,
where a substring expansion where the substring to be removed from
a variable expansion is itself a var expansion where the value
contains one (or more) of sh's CTLxxx chars - the pattern had
CTLESC inserted, the string to be matched against did not.  Fail.
We fix that by always inserting CTLESC in var assign expansions.
See the PR for all the gory details.

Thanks for the PR.

XXX pullup to everything.


To generate a diff of this commit:
cvs rdiff -u -r1.190 -r1.191 src/bin/sh/eval.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/sh/eval.c
diff -u src/bin/sh/eval.c:1.190 src/bin/sh/eval.c:1.191
--- src/bin/sh/eval.c:1.190	Sat Jun 24 05:17:02 2023
+++ src/bin/sh/eval.c	Mon Dec 25 04:52:38 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: eval.c,v 1.190 2023/06/24 05:17:02 msaitoh Exp $	*/
+/*	$NetBSD: eval.c,v 1.191 2023/12/25 04:52:38 kre Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)eval.c	8.9 (Berkeley) 6/8/95";
 #else
-__RCSID("$NetBSD: eval.c,v 1.190 2023/06/24 05:17:02 msaitoh Exp $");
+__RCSID("$NetBSD: eval.c,v 1.191 2023/12/25 04:52:38 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -932,7 +932,8 @@ evalcommand(union node *cmd, int flgs, s
 		line_number = argp->narg.lineno;
 		if (!isassignment(argp->narg.text))
 			break;
-		expandarg(argp, &varlist, EXP_VARTILDE);
+		/* EXP_CASE handles CTL* chars in expansions properly */
+		expandarg(argp, &varlist, EXP_VARTILDE | EXP_CASE);
 	}
 	*varlist.lastp = NULL;
 

Reply via email to