From 85f4b6d5d9f671ab5d51023f9734ff577d70d9ac Mon Sep 17 00:00:00 2001 From: Mu Qiao Date: Thu, 1 Mar 2012 14:50:19 +0800 Subject: Parser: allow ANSI C quoting in expansion values --- bashast/bashast.g | 2 ++ bashast/gunit/expansions.gunit | 2 +- scripts/command_execution.bash | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bashast/bashast.g b/bashast/bashast.g index 98da5e7..700f865 100644 --- a/bashast/bashast.g +++ b/bashast/bashast.g @@ -746,6 +746,8 @@ expansion_base | (ESC TICK) => ESC TICK -> TICK | (ESC DOLLAR) => ESC DOLLAR -> DOLLAR | (brace_expansion) => brace_expansion + | (DOLLAR SINGLE_QUOTED_STRING_TOKEN) => DOLLAR SINGLE_QUOTED_STRING_TOKEN + -> ^(ANSI_C_QUOTING SINGLE_QUOTED_STRING_TOKEN) | .; all_expansions diff --git a/bashast/gunit/expansions.gunit b/bashast/gunit/expansions.gunit index 543012e..39acfa9 100644 --- a/bashast/gunit/expansions.gunit +++ b/bashast/gunit/expansions.gunit @@ -30,4 +30,4 @@ done" -> (LIST (COMMAND (for each (STRING (COMMAND_SUB `ls |grep output`)) (LIST "wc <(cat /usr/share/dict/linux.words)" -> (LIST (COMMAND (STRING wc) (PROCESS_SUBSTITUTION < (LIST (COMMAND (STRING cat) (STRING / usr / share / dict / linux . words)))))) all_expansions: -"abc $(ab) ${ab} $((ab)) `ab` \"ab\" 'ab'" -> (STRING abc (COMMAND_SUB $(ab)) (VAR_REF ab) (ARITHMETIC_EXPRESSION (ARITHMETIC (VAR_REF ab))) (COMMAND_SUB `ab`) (DOUBLE_QUOTED_STRING ab) 'ab') +"$'abc' abc $(ab) ${ab} $((ab)) `ab` \"ab\" 'ab'" -> (STRING (ANSI_C_QUOTING 'abc') abc (COMMAND_SUB $(ab)) (VAR_REF ab) (ARITHMETIC_EXPRESSION (ARITHMETIC (VAR_REF ab))) (COMMAND_SUB `ab`) (DOUBLE_QUOTED_STRING ab) 'ab') diff --git a/scripts/command_execution.bash b/scripts/command_execution.bash index 06d6676..615b13f 100644 --- a/scripts/command_execution.bash +++ b/scripts/command_execution.bash @@ -84,3 +84,4 @@ variable=a echo "${!variable// /_}" echo "${!#// /_}" echo "${!1// /_}" +echo "${!variable// /$'\n'}" -- cgit v1.2.3-65-gdbad