aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMu Qiao <qiaomuf@gentoo.org>2012-03-26 18:14:42 +0800
committerMu Qiao <qiaomuf@gentoo.org>2012-03-26 20:04:43 +0800
commitc8b13641610f4f6b37b15a91f9f5ff390071545e (patch)
tree04cd4916b41090540b95e06bdec74c84226944ed
parentWalker: support appending array to array (diff)
downloadlibbash-c8b13641610f4f6b37b15a91f9f5ff390071545e.tar.gz
libbash-c8b13641610f4f6b37b15a91f9f5ff390071545e.tar.bz2
libbash-c8b13641610f4f6b37b15a91f9f5ff390071545e.zip
Parser&Walker: improve escaped double quote handling
-rw-r--r--bashast/bashast.g3
-rw-r--r--bashast/gunit/fname.gunit2
-rw-r--r--bashast/libbashWalker.g1
-rw-r--r--scripts/command_execution.bash1
4 files changed, 5 insertions, 2 deletions
diff --git a/bashast/bashast.g b/bashast/bashast.g
index c836047..f7ce358 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -784,7 +784,7 @@ ns_string_part
|OTHER|EQUALS|PCT|PCTPCT|PLUS|MINUS|DOT|DOTDOT|COLON
|TILDE|LSQUARE|RSQUARE|CARET|POUND|COMMA|EXPORT|LOCAL|AT
// Escaped characters
- |ESC_RPAREN|ESC_LPAREN|ESC_DOLLAR|ESC_GT|ESC_LT|ESC_TICK
+ |ESC_RPAREN|ESC_LPAREN|ESC_DOLLAR|ESC_GT|ESC_LT|ESC_TICK|ESC_DQUOTE
// The following is for filename expansion
|TIMES|QMARK;
@@ -1126,6 +1126,7 @@ AMP_RSHIFT : '&>>';
SEMIC : ';';
DOUBLE_SEMIC : ';;';
PIPE : '|';
+ESC_DQUOTE : '\\"';
DQUOTE : '"' { if(LA(-1) != '\\') double_quoted = !double_quoted; };
SQUOTE : { double_quoted }? => '\'';
SINGLE_QUOTED_STRING_TOKEN : { !double_quoted }? => '\'' .* '\'';
diff --git a/bashast/gunit/fname.gunit b/bashast/gunit/fname.gunit
index 9ac0b25..65bb614 100644
--- a/bashast/gunit/fname.gunit
+++ b/bashast/gunit/fname.gunit
@@ -77,4 +77,4 @@ condition_expr:
"[[ x == ab!(gh|i) ]]" -> (KEYWORD_TEST (MATCH_PATTERN (STRING x) (STRING ab (EXTENDED_MATCH_NONE (BRANCH gh) (BRANCH i)))))
double_quoted_string:
-"\"\\\\\"\$\`\"" -> (DOUBLE_QUOTED_STRING \ " \$ \`)
+"\"\\\\\"\$\`\"" -> (DOUBLE_QUOTED_STRING \ \" \$ \`)
diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index 5d5b557..fb1ca55 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -446,6 +446,7 @@ options {backtrack = true;}
:ESC_RPAREN { $libbash_value = ")"; }
|ESC_LPAREN { $libbash_value = "("; }
|ESC_DOLLAR { $libbash_value = "$"; }
+ |ESC_DQUOTE { $libbash_value = "\""; }
|ESC_GT { $libbash_value = ">"; }
|ESC_LT { $libbash_value = "<"; }
|ESC_TICK { $libbash_value = "`"; }
diff --git a/scripts/command_execution.bash b/scripts/command_execution.bash
index 89a0ed7..58f1279 100644
--- a/scripts/command_execution.bash
+++ b/scripts/command_execution.bash
@@ -89,3 +89,4 @@ echo "${!variable// /_}"
echo "${!#// /_}"
echo "${!1// /_}"
echo "${!variable// /$'\n'}"
+eval abc+=\( \"\$@\" \)