sh: Do not word split "${#parameter}".

This is only a problem if IFS contains digits, which is unusual but valid.

Because of an incorrect fix for PR bin/12137, "${#parameter}" was treated
as ${#parameter}. The underlying problem was that "${#parameter}"
erroneously added CTLESC bytes before determining the length. This
was properly fixed for PR bin/56147 but the incorrect fix was not backed
out.

Reported by:	Seeker on forums.freebsd.org
MFC after:	2 weeks
This commit is contained in:
Jilles Tjoelker 2011-04-20 22:24:54 +00:00
parent aca2249d54
commit caa7ccdc54
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=220903
2 changed files with 10 additions and 2 deletions

View File

@ -1572,8 +1572,8 @@ parsesub: {
pungetc();
}
STPUTC('=', out);
if (subtype != VSLENGTH && (state[level].syntax == DQSYNTAX ||
state[level].syntax == ARISYNTAX))
if (state[level].syntax == DQSYNTAX ||
state[level].syntax == ARISYNTAX)
flags |= VSQUOTE;
*(stackblock() + typeloc) = subtype | flags;
if (subtype != VSNORMAL) {

View File

@ -0,0 +1,8 @@
# $FreeBSD$
x='!@#$%^&*()[]'
[ ${#x} = 12 ] || echo bad 1
[ "${#x}" = 12 ] || echo bad 2
IFS=2
[ ${#x} = 1 ] || echo bad 3
[ "${#x}" = 12 ] || echo bad 4