ash: fix arithmetic closing )) split by backslash-newline
authorDenys Vlasenko <vda.linux@googlemail.com>
Thu, 29 Sep 2016 15:58:58 +0000 (17:58 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Thu, 29 Sep 2016 15:58:58 +0000 (17:58 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/ash.c
shell/ash_test/ash-vars/var_unbackslash1.right
shell/ash_test/ash-vars/var_unbackslash1.tests
shell/hush_test/hush-vars/var_unbackslash1.right
shell/hush_test/hush-vars/var_unbackslash1.tests

index b71fc02990d47ea45fc2f8c92d14486432e27acb..97f8d9377759fa5bdb8cec0541925d790f7d5ca7 100644 (file)
@@ -11437,7 +11437,7 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs)
                        if (parenlevel > 0) {
                                parenlevel--;
                        } else {
-                               if (pgetc() == ')') {
+                               if (pgetc_eatbnl() == ')') {
                                        c = CTLENDARI;
                                        if (--arinest == 0) {
                                                syntax = prevsyntax;
@@ -11464,6 +11464,7 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs)
                        if (varnest == 0) {
 #if ENABLE_ASH_BASH_COMPAT
                                if (c == '&') {
+//Can't call pgetc_eatbnl() here, this requires three-deep pungetc()
                                        if (pgetc() == '>')
                                                c = 0x100 + '>'; /* flag &> */
                                        pungetc();
index 8d4eca34ed031537bd6b856648cf83c7ea862317..3e0c0e2af07e430cace25c61082e692c8f98323f 100644 (file)
@@ -1,3 +1,7 @@
 Ok
 Ba d
 Ok
+Ok
+Ok
+Forty two:42
+Forty two:42
index 8a9f2e2498b296b61bcb652b101eba177f6e1405..cddd8ae5e1ca6422bad3e7881ed5d7c60ec7a5e1 100755 (executable)
@@ -13,3 +13,23 @@ d'
 eval $e
 # "Ok"
 eval "$e"
+
+echo $\
+(echo Ok\
+)
+echo "$\
+(echo Ok\
+)"
+
+echo Forty two:$\
+(\
+(\
+42\
+)\
+)
+echo "Forty two:$\
+(\
+(\
+42\
+)\
+)"
\ No newline at end of file
index 8d4eca34ed031537bd6b856648cf83c7ea862317..3e0c0e2af07e430cace25c61082e692c8f98323f 100644 (file)
@@ -1,3 +1,7 @@
 Ok
 Ba d
 Ok
+Ok
+Ok
+Forty two:42
+Forty two:42
index 8a9f2e2498b296b61bcb652b101eba177f6e1405..cddd8ae5e1ca6422bad3e7881ed5d7c60ec7a5e1 100755 (executable)
@@ -13,3 +13,23 @@ d'
 eval $e
 # "Ok"
 eval "$e"
+
+echo $\
+(echo Ok\
+)
+echo "$\
+(echo Ok\
+)"
+
+echo Forty two:$\
+(\
+(\
+42\
+)\
+)
+echo "Forty two:$\
+(\
+(\
+42\
+)\
+)"
\ No newline at end of file