From: Peter Avalos Date: Sun, 3 Jul 2011 00:03:42 +0000 (-1000) Subject: sh: Detect an error for ${#var}. X-Git-Tag: v2.12.0~181 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/f41d807a0c7c535d8f66f0593fb6e95fa20f82d4 sh: Detect an error for ${#var}. In particular, this makes things like ${#foo[0]} and ${#foo[@]} errors rather than silent equivalents of ${#foo}. Obtained-from: FreeBSD SVN rev 221461 --- diff --git a/bin/sh/parser.c b/bin/sh/parser.c index 952dcd37e9..7c7a2bfc77 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)parser.c 8.7 (Berkeley) 5/16/95 - * $FreeBSD: src/bin/sh/parser.c,v 1.107 2011/04/20 22:24:54 jilles Exp $ + * $FreeBSD: src/bin/sh/parser.c,v 1.108 2011/05/04 21:49:34 jilles Exp $ */ #include @@ -1568,6 +1568,8 @@ varname: } } } else if (subtype != VSERROR) { + if (subtype == VSLENGTH && c != '}') + subtype = VSERROR; pungetc(); } STPUTC('=', out); diff --git a/tools/regression/bin/sh/errors/bad-parm-exp6.2 b/tools/regression/bin/sh/errors/bad-parm-exp6.2 new file mode 100644 index 0000000000..e214a4a903 --- /dev/null +++ b/tools/regression/bin/sh/errors/bad-parm-exp6.2 @@ -0,0 +1,2 @@ +# $FreeBSD: src/tools/regression/bin/sh/errors/bad-parm-exp6.2,v 1.1 2011/05/04 21:49:34 jilles Exp $ +${#foo^} diff --git a/tools/regression/bin/sh/errors/bad-parm-exp6.2.stderr b/tools/regression/bin/sh/errors/bad-parm-exp6.2.stderr new file mode 100644 index 0000000000..dbf14b596e --- /dev/null +++ b/tools/regression/bin/sh/errors/bad-parm-exp6.2.stderr @@ -0,0 +1 @@ +./errors/bad-parm-exp6.2: ${foo...}: Bad substitution