aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMu Qiao <qiaomuf@gentoo.org>2011-06-06 18:21:58 +0800
committerMu Qiao <qiaomuf@gentoo.org>2011-06-11 16:49:51 +0800
commit5cc91900c887df1209b59f0357718c78d2d5ca4e (patch)
tree399595b097893aca8aea1d341ed92df5ca9ca24e /scripts
parentWalker: support array offset expansion (diff)
downloadlibbash-5cc91900c887df1209b59f0357718c78d2d5ca4e.tar.gz
libbash-5cc91900c887df1209b59f0357718c78d2d5ca4e.tar.bz2
libbash-5cc91900c887df1209b59f0357718c78d2d5ca4e.zip
Walker: simplify variable reference
$* and $@ are treated equally now. This will simplify the grammar and we won't differentiate them until this causes any problem. $@ is supported in walker grammar with this change.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/var_def.bash2
-rw-r--r--scripts/var_def.bash.result1
-rw-r--r--scripts/var_expansion.bash20
-rw-r--r--scripts/var_expansion.bash.result17
4 files changed, 26 insertions, 14 deletions
diff --git a/scripts/var_def.bash b/scripts/var_def.bash
index f832a96..1980681 100644
--- a/scripts/var_def.bash
+++ b/scripts/var_def.bash
@@ -35,8 +35,6 @@ ARRAY10="${ARRAY05[*]}"
FOO001="networkmanager"
FOO002="0.8.2"
FOO003=${FOO001}-${FOO002}
-FOO004=$*
-FOO004=$@
FOO004=$#
FOO004=$?
FOO004=$-
diff --git a/scripts/var_def.bash.result b/scripts/var_def.bash.result
index 121c267..5ab9882 100644
--- a/scripts/var_def.bash.result
+++ b/scripts/var_def.bash.result
@@ -1,4 +1,3 @@
-$@ has not been implemented yet
$# has not been implemented yet
$- has not been implemented yet
$! has not been implemented yet
diff --git a/scripts/var_expansion.bash b/scripts/var_expansion.bash
index c3f41d3..1ac22b4 100644
--- a/scripts/var_expansion.bash
+++ b/scripts/var_expansion.bash
@@ -84,12 +84,20 @@ FOO081=${FOO039//@([a-c]|[k-m])}
target="abc123abc"
FOO082="${target##+(ab[c])*([[:digit:]])}"
function positional_parameter_test(){
- FOO083=${*}
- FOO084=${*:1}
- FOO085=${*:1:2}
- FOO086=${*: -1}
- FOO087=${*: -2:5}
- FOO088=${*:0}
+ FOO083=$*
+ FOO084=${*}
+ FOO085=${*:1}
+ FOO086=${*:1:2}
+ FOO087=${*: -1}
+ FOO088=${*: -2:5}
+ FOO089=${*:0}
+ FOO090=$@
+ FOO091=${@}
+ FOO092=${@:1}
+ FOO093=${@:1:2}
+ FOO094=${@: -1}
+ FOO095=${@: -2:5}
+ FOO096=${@:0}
}
positional_parameter_test 1 2 3 4 5
target="abc*abc"
diff --git a/scripts/var_expansion.bash.result b/scripts/var_expansion.bash.result
index 299d975..31cca8d 100644
--- a/scripts/var_expansion.bash.result
+++ b/scripts/var_expansion.bash.result
@@ -90,9 +90,16 @@ FOO081=Heo Word
FOO082=abc
FOO083=1 2 3 4 5
FOO084=1 2 3 4 5
-FOO085=1 2
-FOO086=5
-FOO087=4 5
-FOO088=@srcdir@/scripts/var_expansion.bash 1 2 3 4 5
-FOO089=
+FOO085=1 2 3 4 5
+FOO086=1 2
+FOO087=5
+FOO088=4 5
+FOO089=@srcdir@/scripts/var_expansion.bash 1 2 3 4 5
+FOO090=1 2 3 4 5
+FOO091=1 2 3 4 5
+FOO092=1 2 3 4 5
+FOO093=1 2
+FOO094=5
+FOO095=4 5
+FOO096=@srcdir@/scripts/var_expansion.bash 1 2 3 4 5
target=abc*abc