sh: Do not word split "${#parameter}".
authorPeter Avalos <pavalos@dragonflybsd.org>
Sat, 2 Jul 2011 23:28:01 +0000 (13:28 -1000)
committerPeter Avalos <pavalos@dragonflybsd.org>
Sun, 21 Aug 2011 19:10:23 +0000 (12:10 -0700)
This is only a problem if IFS contains digits, which is unusual but
valid.

Obtained-from:   FreeBSD SVN rev 221522

bin/sh/parser.c
tools/regression/bin/sh/expansion/length6.0 [new file with mode: 0644]

index 74e7cbd..952dcd3 100644 (file)
@@ -34,7 +34,7 @@
  * SUCH DAMAGE.
  *
  * @(#)parser.c        8.7 (Berkeley) 5/16/95
- * $FreeBSD: src/bin/sh/parser.c,v 1.106 2011/03/13 20:02:39 jilles Exp $
+ * $FreeBSD: src/bin/sh/parser.c,v 1.107 2011/04/20 22:24:54 jilles Exp $
  */
 
 #include <stdio.h>
@@ -1571,8 +1571,8 @@ varname:
                        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) {
diff --git a/tools/regression/bin/sh/expansion/length6.0 b/tools/regression/bin/sh/expansion/length6.0
new file mode 100644 (file)
index 0000000..166249a
--- /dev/null
@@ -0,0 +1,8 @@
+# $FreeBSD: src/tools/regression/bin/sh/expansion/length6.0,v 1.1 2011/04/20 22:24:54 jilles Exp $
+
+x='!@#$%^&*()[]'
+[ ${#x} = 12 ] || echo bad 1
+[ "${#x}" = 12 ] || echo bad 2
+IFS=2
+[ ${#x} = 1 ] || echo bad 3
+[ "${#x}" = 12 ] || echo bad 4