1 |
commit: 62f2e7c112601d5bc7e7f5d042d4fce1e354865e |
2 |
Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Mar 1 07:51:58 2012 +0000 |
4 |
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Mar 1 07:51:58 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=62f2e7c1 |
7 |
|
8 |
Parser: allow empty replacement pattern |
9 |
|
10 |
--- |
11 |
bashast/bashast.g | 3 ++- |
12 |
bashast/gunit/param_main.gunit | 3 +++ |
13 |
scripts/var_expansion.bash | 5 +++++ |
14 |
3 files changed, 10 insertions(+), 1 deletions(-) |
15 |
|
16 |
diff --git a/bashast/bashast.g b/bashast/bashast.g |
17 |
index 8d627c4..73249ef 100644 |
18 |
--- a/bashast/bashast.g |
19 |
+++ b/bashast/bashast.g |
20 |
@@ -879,7 +879,8 @@ parameter_value_operator |
21 |
| QMARK -> DISPLAY_ERROR_WHEN_UNSET |
22 |
| PLUS -> USE_ALTERNATE_WHEN_UNSET; |
23 |
parameter_replace_pattern |
24 |
- : ((~SLASH) => parameter_pattern_part)+ -> ^(STRING parameter_pattern_part+); |
25 |
+ : (SLASH) => -> ^(STRING NAME) // Create an empty string |
26 |
+ | ((~SLASH) => parameter_pattern_part)+ -> ^(STRING parameter_pattern_part+); |
27 |
parameter_delete_pattern |
28 |
: parameter_pattern_part+ -> ^(STRING parameter_pattern_part+); |
29 |
parameter_pattern_part |
30 |
|
31 |
diff --git a/bashast/gunit/param_main.gunit b/bashast/gunit/param_main.gunit |
32 |
index 01ec853..2168d54 100644 |
33 |
--- a/bashast/gunit/param_main.gunit |
34 |
+++ b/bashast/gunit/param_main.gunit |
35 |
@@ -90,6 +90,9 @@ variable_reference: |
36 |
"${!#/a/bc}" -> (VAR_REF (REPLACE_FIRST (VAR_REF #) (STRING a) (STRING bc))) |
37 |
"${!abc/a/bc}" -> (VAR_REF (REPLACE_FIRST (VAR_REF abc) (STRING a) (STRING bc))) |
38 |
"${!123/a/bc}" -> (VAR_REF (REPLACE_FIRST (VAR_REF 123) (STRING a) (STRING bc))) |
39 |
+"${search_paths/%/${root}}" -> (VAR_REF (REPLACE_AT_END search_paths (STRING NAME) (STRING $ { root }))) |
40 |
+"${search_paths/#/${root}}" -> (VAR_REF (REPLACE_AT_START search_paths (STRING NAME) (STRING $ { root }))) |
41 |
+"${search_paths//${root}}" -> (VAR_REF (REPLACE_ALL search_paths (STRING (VAR_REF root)))) |
42 |
|
43 |
variable_definition_atom: |
44 |
"MY_PN=${PN/asterisk-}" -> (= MY_PN (STRING (VAR_REF (REPLACE_FIRST PN (STRING asterisk -))))) |
45 |
|
46 |
diff --git a/scripts/var_expansion.bash b/scripts/var_expansion.bash |
47 |
index 5f0bfca..e78ac8f 100644 |
48 |
--- a/scripts/var_expansion.bash |
49 |
+++ b/scripts/var_expansion.bash |
50 |
@@ -130,6 +130,11 @@ foo= |
51 |
unset bar |
52 |
echo ${bar=abc} |
53 |
|
54 |
+search_paths="a%#b" |
55 |
+root=123 |
56 |
+echo "${search_paths/%/${root}}" |
57 |
+echo "${search_paths/#/${root}}" |
58 |
+ |
59 |
# This regular expression will cause boost::exception_detail::clone_impl<boost::xpressive::regex_error> |
60 |
#[[ "${version_components_groups}" =~ ("*".*" "|" *"|^2.*\ (2|\*)|^3.*\ (3|\*)) ]] |
61 |
[[ " ${FUNCNAME[@]:2} " =~ " "(_python_final_sanity_checks|python_execute_function|python_mod_optimize|python_mod_cleanup)" " ]] |