Pull up following revision(s) (requested by kre in ticket #1787):
bin/sh/eval.c: revision 1.191 bin/sh/expand.c: revision 1.144 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. PR bin/57773 Fix another bug reported by Jarle Fredrik Greipsland and added to PR bin/57773, which relates to calculating the length of a positional parameter which contains CTL chars -- yes, this one really is that specific, though it would also affect the special param $0 if it were to contain CTL chars, and its length was requested - that is fixed with the same change. And note: $0 is not affected because it looks like a positional param (it isn't, ${00} would be, but is always unset, ${0} isn't) all special parame would be affected the same way, but the only one that can ever contain a CTL char is $0 I believe. ($@ and $* were affected, but just because they're expanding the positional params ... ${#@} and ${#*} are both technically unspecified expansions - and different shells produce different results. See the PR for the details of this one (and the previous). Thanks for the PR.
This commit is contained in:
parent
0a8340c6d1
commit
2c4203e814
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: eval.c,v 1.175.2.3 2021/04/28 09:58:42 martin Exp $ */
|
||||
/* $NetBSD: eval.c,v 1.175.2.4 2024/01/14 13:16:51 martin 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.175.2.3 2021/04/28 09:58:42 martin Exp $");
|
||||
__RCSID("$NetBSD: eval.c,v 1.175.2.4 2024/01/14 13:16:51 martin Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -908,7 +908,8 @@ evalcommand(union node *cmd, int flgs, struct backcmd *backcmd)
|
|||
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;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: expand.c,v 1.132.2.2 2020/06/07 12:50:17 martin Exp $ */
|
||||
/* $NetBSD: expand.c,v 1.132.2.3 2024/01/14 13:16:51 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
|
@ -37,7 +37,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)expand.c 8.5 (Berkeley) 5/15/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: expand.c,v 1.132.2.2 2020/06/07 12:50:17 martin Exp $");
|
||||
__RCSID("$NetBSD: expand.c,v 1.132.2.3 2024/01/14 13:16:51 martin Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -1182,7 +1182,7 @@ varvalue(const char *name, int quoted, int subtype, int flag)
|
|||
quoted ? ", quoted" : "", subtype, flag));
|
||||
|
||||
if (subtype == VSLENGTH) /* no magic required ... */
|
||||
flag &= ~EXP_FULL;
|
||||
flag &= ~(EXP_FULL | EXP_QNEEDED);
|
||||
|
||||
#define STRTODEST(p) \
|
||||
do {\
|
||||
|
@ -1194,7 +1194,7 @@ varvalue(const char *name, int quoted, int subtype, int flag)
|
|||
} \
|
||||
} else \
|
||||
while (*p) { \
|
||||
if (ISCTL(*p)) \
|
||||
if ((flag & EXP_QNEEDED) && ISCTL(*p)) \
|
||||
STPUTC(CTLESC, expdest); \
|
||||
STPUTC(*p++, expdest); \
|
||||
} \
|
||||
|
|
Loading…
Reference in New Issue