From: "Petteri Räty" <betelgeuse@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/libbash:master commit in: scripts/, bashast/, bashast/gunit/
Date: Thu, 4 Aug 2011 13:53:44 +0000 (UTC) [thread overview]
Message-ID: <1edf5ee2f0f778282b3d967d65a5028844fada29.betelgeuse@gentoo> (raw)
commit: 1edf5ee2f0f778282b3d967d65a5028844fada29
Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 28 07:40:00 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Tue Aug 2 07:52:18 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=1edf5ee2
Walker: support brace expansion for local and export
---
bashast/bashast.g | 4 ++--
bashast/gunit/pipeline.gunit | 2 +-
bashast/gunit/simp_command.gunit | 2 +-
bashast/libbashWalker.g | 8 +++++---
scripts/command_execution.bash | 1 +
5 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index cb0a63d..818a598 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -379,9 +379,9 @@ command_atom
| -> ^(VARIABLE_DEFINITIONS variable_definitions)
)
| (EXPORT) => EXPORT BLANK builtin_variable_definition_item
- -> ^(STRING EXPORT) ^(STRING ^(DOUBLE_QUOTED_STRING builtin_variable_definition_item))
+ -> ^(STRING EXPORT) ^(STRING builtin_variable_definition_item)
| (LOCAL) => LOCAL BLANK builtin_variable_definition_item
- -> ^(STRING LOCAL) ^(STRING ^(DOUBLE_QUOTED_STRING builtin_variable_definition_item))
+ -> ^(STRING LOCAL) ^(STRING builtin_variable_definition_item)
| command_name
(
(BLANK? parens) => BLANK? parens wspace? compound_command
diff --git a/bashast/gunit/pipeline.gunit b/bashast/gunit/pipeline.gunit
index 8f6dd43..aea66f0 100644
--- a/bashast/gunit/pipeline.gunit
+++ b/bashast/gunit/pipeline.gunit
@@ -20,7 +20,7 @@ gunit java_libbash;
pipeline:
"cat asdf" -> (COMMAND (STRING cat) (STRING asdf))
-"export VAR=bar LAA=(1 2 3) foo" -> (COMMAND (STRING export) (STRING (DOUBLE_QUOTED_STRING VAR = bar LAA = ( 1 2 3 ) foo)))
+"export VAR=bar LAA=(1 2 3) foo" -> (COMMAND (STRING export) (STRING VAR = bar LAA = ( 1 2 3 ) foo))
"LOCAL1=a LOCAL2=b export GLOBAL1=2 GLOBAL2 GLOBAL3" -> (COMMAND (STRING export) (STRING GLOBAL1 = 2) (STRING GLOBAL2) (STRING GLOBAL3) (= LOCAL1 (STRING a)) (= LOCAL2 (STRING b)))
"time -p cat file" -> (COMMAND (STRING cat) (STRING file) (time p))
"time cat file | grep search" -> (| (COMMAND (STRING cat) (STRING file) time) (COMMAND (STRING grep) (STRING search)))
diff --git a/bashast/gunit/simp_command.gunit b/bashast/gunit/simp_command.gunit
index 2d98061..e6a8602 100644
--- a/bashast/gunit/simp_command.gunit
+++ b/bashast/gunit/simp_command.gunit
@@ -27,7 +27,7 @@ command_atom:
"./foobär" -> (STRING . / foob ä r)
"cat ~/Documents/todo.txt" -> (STRING cat) (STRING ~ / Documents / todo . txt)
"dodir ${foo}/${bar}" -> (STRING dodir) (STRING (VAR_REF foo) / (VAR_REF bar))
-"local a=123 b=(1 2 3) c" -> (STRING local) (STRING (DOUBLE_QUOTED_STRING a = 123 b = ( 1 2 3 ) c))
+"local a=123 b=(1 2 3) c" -> (STRING local) (STRING a = 123 b = ( 1 2 3 ) c)
"echo {}{}}{{{}}{{}" -> (STRING echo) (STRING { } { } } { { { } } { { })
"echo \"ab#af ###\" #abc" -> (STRING echo) (STRING (DOUBLE_QUOTED_STRING ab # af # # #))
diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index 65fade5..fc05b91 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -576,8 +576,10 @@ command_atom
simple_command
@declarations {
std::vector<std::string> libbash_args;
+ bool split;
}
- :string_expr (argument[libbash_args])* execute_command[$string_expr.libbash_value, libbash_args];
+ :string_expr{ split = ($string_expr.libbash_value != "local" && $string_expr.libbash_value != "export"); }
+ (argument[libbash_args, split])* execute_command[$string_expr.libbash_value, libbash_args];
execute_command[std::string& name, std::vector<std::string>& libbash_args]
@declarations {
@@ -664,11 +666,11 @@ redirect_destination_input[std::unique_ptr<std::istream>& in]
std::cerr << "FILE_DESCRIPTOR_MOVE redirection is not supported yet" << std::endl;
};
-argument[std::vector<std::string>& args]
+argument[std::vector<std::string>& args, bool split]
: string_expr {
if(!$string_expr.libbash_value.empty())
{
- if($string_expr.quoted)
+ if($string_expr.quoted || !split)
args.push_back($string_expr.libbash_value);
else
walker->split_word($string_expr.libbash_value, args);
diff --git a/scripts/command_execution.bash b/scripts/command_execution.bash
index 1721fa9..a10d229 100644
--- a/scripts/command_execution.bash
+++ b/scripts/command_execution.bash
@@ -35,6 +35,7 @@ function unset_outer()
{
local FOO006=1 FOO007=2
local gjl_${FOO006}="${FOO007}"
+ local f version install{{site,vendor}{arch,lib},archlib}
unset_inner
echo "FOO006=$FOO006 in unset_outer"
echo "FOO007=$FOO007 in unset_outer"
next reply other threads:[~2011-08-04 13:56 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-04 13:53 Petteri Räty [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-06-03 9:08 [gentoo-commits] proj/libbash:master commit in: scripts/, bashast/, bashast/gunit/ Petteri Räty
2012-06-03 9:08 Petteri Räty
2012-06-03 9:08 Petteri Räty
2012-06-03 9:08 Petteri Räty
2012-06-03 9:08 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-06-09 8:15 Petteri Räty
2011-06-09 7:27 Petteri Räty
2011-05-22 21:00 Petteri Räty
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1edf5ee2f0f778282b3d967d65a5028844fada29.betelgeuse@gentoo \
--to=betelgeuse@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox