sh: Detect an error for ${#var<GARBAGE>}.

In particular, this makes things like ${#foo[0]} and ${#foo[@]} errors
rather than silent equivalents of ${#foo}.

PR:		bin/151720
Submitted by:	Mark Johnston
Exp-run done by: pav (with some other sh(1) changes)
This commit is contained in:
Jilles Tjoelker 2011-05-04 21:49:34 +00:00
parent c3d72c80d3
commit fc0818fef3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=221461
3 changed files with 5 additions and 0 deletions

View File

@ -1569,6 +1569,8 @@ parsesub: {
}
}
} else if (subtype != VSERROR) {
if (subtype == VSLENGTH && c != '}')
subtype = VSERROR;
pungetc();
}
STPUTC('=', out);

View File

@ -0,0 +1,2 @@
# $FreeBSD$
${#foo^}

View File

@ -0,0 +1 @@
./errors/bad-parm-exp6.2: ${foo...}: Bad substitution