aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMu Qiao <qiaomuf@gentoo.org>2012-02-29 16:08:04 +0800
committerMu Qiao <qiaomuf@gentoo.org>2012-02-29 16:08:04 +0800
commitd418891be2a8428a4b1edc82a7b964b0c6b34d6e (patch)
tree6767b406f21a4f98a924e8d5aba92b52a43d6523
parentParser&Walker: allow multiple arithmetic expressions (diff)
downloadlibbash-d418891be2a8428a4b1edc82a7b964b0c6b34d6e.tar.gz
libbash-d418891be2a8428a4b1edc82a7b964b0c6b34d6e.tar.bz2
libbash-d418891be2a8428a4b1edc82a7b964b0c6b34d6e.zip
Parser: allow double quotes in arithmetic expression
-rw-r--r--bashast/bashast.g2
-rw-r--r--scripts/binary_arithmetic.bash6
-rw-r--r--scripts/compound_command.bash5
3 files changed, 12 insertions, 1 deletions
diff --git a/bashast/bashast.g b/bashast/bashast.g
index ded2fab..0be9b46 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -1005,7 +1005,7 @@ primary
| arithmetic_expansion
| LPAREN! (arithmetics) RPAREN!;
pre_post_primary
- : primary;
+ : DQUOTE!? primary DQUOTE!?;
post_inc_dec
: pre_post_primary ((BLANK) => BLANK)?
(
diff --git a/scripts/binary_arithmetic.bash b/scripts/binary_arithmetic.bash
index c5f018c..db7dcb7 100644
--- a/scripts/binary_arithmetic.bash
+++ b/scripts/binary_arithmetic.bash
@@ -70,3 +70,9 @@ echo "$((0&&FOO059++))"
echo "$(( 1 == 2))"
echo "$(( 1 == 1))"
echo $(($((1))))
+(( a= "1+ 1"*2))
+echo $a
+FOO="3 * 2"
+echo $(( $FOO + 1 ))
+FOO="3, b = 2"
+echo $(( $FOO + 1 ))
diff --git a/scripts/compound_command.bash b/scripts/compound_command.bash
index 0db8ff8..0d3321e 100644
--- a/scripts/compound_command.bash
+++ b/scripts/compound_command.bash
@@ -356,3 +356,8 @@ for((i=1,j=2;i!=2&&j!=4;++i))
do
echo $i $j
done
+python_versions=(2.6 2.7 3.0 3.1)
+for ((i = "${#python_versions[@]}"; i >= 0; i--))
+do
+ echo $i
+done