aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMu Qiao <qiaomuf@gentoo.org>2012-03-01 11:32:58 +0800
committerMu Qiao <qiaomuf@gentoo.org>2012-03-01 11:32:58 +0800
commit66be73c1d8a0c253d34ee76206982e3cf12954b7 (patch)
treec7dca3aa92e923eb9d4e9c505e6e1017f429aa24
parentParser: support indirect ref in parameter expansion (diff)
downloadlibbash-66be73c1d8a0c253d34ee76206982e3cf12954b7.tar.gz
libbash-66be73c1d8a0c253d34ee76206982e3cf12954b7.tar.bz2
libbash-66be73c1d8a0c253d34ee76206982e3cf12954b7.zip
Walker: support indirect ref in runtime
-rw-r--r--bashast/bashast.g2
-rw-r--r--scripts/command_execution.bash5
2 files changed, 6 insertions, 1 deletions
diff --git a/bashast/bashast.g b/bashast/bashast.g
index 0be9b46..98da5e7 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -860,7 +860,6 @@ parameter_expansion
TIMES -> ^(BANG variable_name_for_bang TIMES)
| AT -> ^(BANG variable_name_for_bang AT)
| LSQUARE (op=TIMES|op=AT) RSQUARE -> ^(LIST_EXPAND variable_name_for_bang $op)
- | -> ^(VAR_REF variable_name_for_bang)
)
| {LA(1) == POUND && LA(2) != RBRACE }? => variable_size_ref;
parameter_delete_operator
@@ -915,6 +914,7 @@ variable_name
: num
| name LSQUARE AT RSQUARE -> ^(ARRAY name AT)
| name LSQUARE TIMES RSQUARE -> ^(ARRAY name TIMES)
+ | BANG variable_name_for_bang -> ^(VAR_REF variable_name_for_bang)
| variable_name_no_digit
| DOLLAR
| TIMES
diff --git a/scripts/command_execution.bash b/scripts/command_execution.bash
index e400409..06d6676 100644
--- a/scripts/command_execution.bash
+++ b/scripts/command_execution.bash
@@ -79,3 +79,8 @@ echo \`\(\)\$\>\<\`
export SRC_URI="${SRC_URI} http://www.oracle.com/technology/products/berkeley-db/db/update/${MY_PV}/patch.${MY_PV}.${i}"
> /dev/null
(( i=1, j=2)) && echo $i $j
+a="ab cd ef"
+variable=a
+echo "${!variable// /_}"
+echo "${!#// /_}"
+echo "${!1// /_}"