diff options
author | Mu Qiao <qiaomuf@gentoo.org> | 2011-07-19 22:24:07 +0800 |
---|---|---|
committer | Mu Qiao <qiaomuf@gentoo.org> | 2011-07-20 23:08:32 +0800 |
commit | c362dfac46df8e73df50a0694e59f5087104ad2b (patch) | |
tree | 965df68b4712d2b98b8e67f98f2a4f76733389a2 /bashast/gunit | |
parent | Build: remove the time limit option (diff) | |
download | libbash-c362dfac46df8e73df50a0694e59f5087104ad2b.tar.gz libbash-c362dfac46df8e73df50a0694e59f5087104ad2b.tar.bz2 libbash-c362dfac46df8e73df50a0694e59f5087104ad2b.zip |
Parser: fix parameter expansion value
Now the rule for expansion value follows bash manual. The delete
expansion is fixed to use the replace pattern rule rather than the
expansion value rule.
Diffstat (limited to 'bashast/gunit')
-rw-r--r-- | bashast/gunit/param_main.gunit | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/bashast/gunit/param_main.gunit b/bashast/gunit/param_main.gunit index 0744004..f2b8cbb 100644 --- a/bashast/gunit/param_main.gunit +++ b/bashast/gunit/param_main.gunit @@ -23,8 +23,8 @@ variable_reference: "${asdf}" -> (VAR_REF asdf) "${asdf:-foo}" -> (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING foo))) "${asdf:-public_html}" -> (VAR_REF (USE_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING public_html))) -"${asdf='foo'}" -> (VAR_REF (ASSIGN_DEFAULT_WHEN_UNSET asdf (STRING (SINGLE_QUOTED_STRING 'foo')))) -//"${asdf:=}" -> (VAR_REF (ASSIGN_DEFAULT_WHEN_UNSET_OR_NULL asdf STRING)) +"${asdf='foo'}" -> (VAR_REF (ASSIGN_DEFAULT_WHEN_UNSET asdf (STRING 'foo'))) +"${asdf:=}" -> (VAR_REF (ASSIGN_DEFAULT_WHEN_UNSET_OR_NULL asdf (STRING EMPTY_EXPANSION_VALUE))) "${bar:7}" -> (VAR_REF (OFFSET bar 7)) "${bar: -10}" -> (VAR_REF (OFFSET bar (MINUS_SIGN 10))) "${bar:(-10 + 5)}" -> (VAR_REF (OFFSET bar (+ (MINUS_SIGN 10) 5))) @@ -41,8 +41,8 @@ variable_reference: "${foo##bar}" -> (VAR_REF (REPLACE_AT_START foo (STRING bar))) "${foo%bar}" -> (VAR_REF (LAZY_REMOVE_AT_END foo (STRING bar))) "${foo%%bar}" -> (VAR_REF (REPLACE_AT_END foo (STRING bar))) -//"${foo%; *}" -> (VAR_REF (LAZY_REMOVE_AT_END foo (STRING ; MATCH_ALL))) -"${foo%/}" -> (VAR_REF (LAZY_REMOVE_AT_END foo (STRING /))) +"${foo%; *}" -> (VAR_REF (LAZY_REMOVE_AT_END foo (STRING ; MATCH_ALL))) +//"${foo%/}" -> (VAR_REF (LAZY_REMOVE_AT_END foo (STRING /))) "${this/is/pattern}"->(VAR_REF (REPLACE_FIRST this (STRING is) (STRING pattern))) //Test positional/special parameters "$1" -> (VAR_REF 1) @@ -60,12 +60,14 @@ variable_reference: "${$}" -> (VAR_REF $) "${PV//./_}" -> (VAR_REF (REPLACE_ALL PV (STRING .) (STRING _))) "${PV// }" -> (VAR_REF (REPLACE_ALL PV (STRING ))) -//"${PV//[-._]/}" -> (VAR_REF (REPLACE_ALL PV (STRING (MATCH_ANY - . _)) STRING)) -"${PV/${pattern}/${replace}}" -> (VAR_REF (REPLACE_FIRST PV (STRING (VAR_REF pattern)) (STRING (VAR_REF replace)))) +"${PV//[-._]/}" -> (VAR_REF (REPLACE_ALL PV (STRING (MATCH_ANY - . _)) (STRING EMPTY_EXPANSION_VALUE))) +"${PV/${pattern}/${replace}}" -> (VAR_REF (REPLACE_FIRST PV (STRING (VAR_REF pattern)) (STRING $ { replace }))) "${PV/#foo/bar}" -> (VAR_REF (REPLACE_AT_START PV (STRING foo) (STRING bar))) "${PV/%foo/bar}" -> (VAR_REF (REPLACE_AT_END PV (STRING foo) (STRING bar))) "${PN/%spaces /more }" -> (VAR_REF (REPLACE_AT_END PN (STRING spaces ) (STRING more ))) "${PN/wrong#/#correct}" -> (VAR_REF (REPLACE_FIRST PN (STRING wrong #) (STRING # correct))) +"${a/b/\}c}" -> (VAR_REF (REPLACE_FIRST a (STRING b) (STRING \ } c))) +"${a/b/a\}c}" -> (VAR_REF (REPLACE_FIRST a (STRING b) (STRING a \ } c))) variable_definition_atom: "MY_PN=${PN/asterisk-}" -> (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -))))) |