summaryrefslogtreecommitdiffstats
path: root/bin/ksh/eval.c
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2019-02-20 23:59:17 +0000
committerschwarze <schwarze@openbsd.org>2019-02-20 23:59:17 +0000
commit0ac57757bcdd34e94e3e2d3b05ea4601a6b10e8a (patch)
treef6a00a43dd03071d9f0e35053410e7c95c198f6b /bin/ksh/eval.c
parentAdd a test that catches problems of tcp md5 signatures, like the one (diff)
downloadwireguard-openbsd-0ac57757bcdd34e94e3e2d3b05ea4601a6b10e8a.tar.xz
wireguard-openbsd-0ac57757bcdd34e94e3e2d3b05ea4601a6b10e8a.zip
When evaluating an arithmetical expression, for example inside $(()),
never do substitution (neither parameter, nor command, nor arithmetic, nor tilde substitution) on the values of any variables encountered inside the expression, but do recursively perform arithmetical evaluation of subexpressions as required. This makes behaviour more consistent, without hindering any behaviour promised in the manual page. A quirk originally reported by Andy Chu <andychup at gmail dot com> was that in the past, when encountering an array index, the shell would not only do evaluation, but also substitution on the array index, even though substitution would not be done on the expression in general. tobias@ contributed to initial efforts of understanding the quirk. patch tested in a bulk build by naddy@ "please commit" deraadt@
Diffstat (limited to 'bin/ksh/eval.c')
-rw-r--r--bin/ksh/eval.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/bin/ksh/eval.c b/bin/ksh/eval.c
index 5232b79a703..5791d7348b6 100644
--- a/bin/ksh/eval.c
+++ b/bin/ksh/eval.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eval.c,v 1.63 2018/07/09 00:20:35 anton Exp $ */
+/* $OpenBSD: eval.c,v 1.64 2019/02/20 23:59:17 schwarze Exp $ */
/*
* Expansion - quoting, separation, substitution, globbing
@@ -66,6 +66,9 @@ substitute(const char *cp, int f)
{
struct source *s, *sold;
+ if (disable_subst)
+ return str_save(cp, ATEMP);
+
sold = source;
s = pushs(SWSTR, ATEMP);
s->start = s->str = cp;