ash: parser: Only accept single-digit parameter expansion outside of braces
authorDenys Vlasenko <vda.linux@googlemail.com>
Mon, 17 Feb 2020 09:15:35 +0000 (10:15 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 17 Feb 2020 09:15:35 +0000 (10:15 +0100)
Upstream commit:

    Date: Mon, 27 May 2019 13:39:37 +0800
    parser: Only accept single-digit parameter expansion outside of braces

    This patch should fix the problem.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/ash.c
shell/ash_test/ash-vars/var_10.right [new file with mode: 0644]
shell/ash_test/ash-vars/var_10.tests [new file with mode: 0755]
shell/hush_test/hush-vars/var_10.right [new file with mode: 0644]
shell/hush_test/hush-vars/var_10.tests [new file with mode: 0755]

index a25d14de010a1a415260f67775e9f88cc33d5b8b..90496ba7e84b50f84ff16acd6c9bf98c12e91f88 100644 (file)
@@ -12602,7 +12602,7 @@ parsesub: {
                        do {
                                STPUTC(c, out);
                                c = pgetc_eatbnl();
-                       } while (isdigit(c));
+                       } while (!subtype && isdigit(c));
                } else if (c != '}') {
                        /* $[{[#]]<specialchar>[}] */
                        int cc = c;
diff --git a/shell/ash_test/ash-vars/var_10.right b/shell/ash_test/ash-vars/var_10.right
new file mode 100644 (file)
index 0000000..675ab45
--- /dev/null
@@ -0,0 +1,3 @@
+Zero:0
+One:1
+Done:0
diff --git a/shell/ash_test/ash-vars/var_10.tests b/shell/ash_test/ash-vars/var_10.tests
new file mode 100755 (executable)
index 0000000..7364efb
--- /dev/null
@@ -0,0 +1,4 @@
+set -- : 2 3 4 5 6 7 8 9 ten eleven
+echo Zero$10
+echo One$11
+echo Done:$?
diff --git a/shell/hush_test/hush-vars/var_10.right b/shell/hush_test/hush-vars/var_10.right
new file mode 100644 (file)
index 0000000..675ab45
--- /dev/null
@@ -0,0 +1,3 @@
+Zero:0
+One:1
+Done:0
diff --git a/shell/hush_test/hush-vars/var_10.tests b/shell/hush_test/hush-vars/var_10.tests
new file mode 100755 (executable)
index 0000000..7364efb
--- /dev/null
@@ -0,0 +1,4 @@
+set -- : 2 3 4 5 6 7 8 9 ten eleven
+echo Zero$10
+echo One$11
+echo Done:$?