Gentoo Archives: gentoo-commits

From: "Petteri Räty" <betelgeuse@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/libbash:master commit in: bashast/, bashast/gunit/
Date: Wed, 01 Jun 2011 12:03:41
Message-Id: 456744a2e9f0cae3231a02763ca852945c0e6c24.betelgeuse@gentoo
1 commit: 456744a2e9f0cae3231a02763ca852945c0e6c24
2 Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
3 AuthorDate: Mon May 30 07:56:30 2011 +0000
4 Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
5 CommitDate: Wed Jun 1 05:54:41 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=456744a2
7
8 Parser: support redirection for command group
9
10 Redirection in function definition is not necessary anymore as it
11 will be matched by command group.
12
13 ---
14 bashast/bashast.g | 8 ++++----
15 bashast/gunit/function.gunit | 6 +++---
16 bashast/gunit/list.gunit | 2 ++
17 3 files changed, 9 insertions(+), 7 deletions(-)
18
19 diff --git a/bashast/bashast.g b/bashast/bashast.g
20 index 2e892c2..26d362f 100644
21 --- a/bashast/bashast.g
22 +++ b/bashast/bashast.g
23 @@ -231,10 +231,10 @@ case_pattern
24 | fname
25 | TIMES;
26 //A grouping of commands executed in a subshell
27 -subshell: LPAREN wspace? clist (BLANK* SEMIC)? (BLANK* EOL)* BLANK* RPAREN -> ^(SUBSHELL clist);
28 +subshell: LPAREN wspace? clist (BLANK* SEMIC)? (BLANK* EOL)* BLANK* RPAREN redirect* -> ^(SUBSHELL clist redirect*);
29 //A grouping of commands executed in the current shell
30 current_shell
31 - : LBRACE wspace clist semiel wspace* RBRACE -> ^(CURRENT_SHELL clist);
32 + : LBRACE wspace clist semiel wspace* RBRACE redirect* -> ^(CURRENT_SHELL clist redirect*);
33 //comparison using arithmetic
34 arith_comparison
35 : LLPAREN wspace? arithmetic wspace? RRPAREN -> ^(COMPOUND_ARITH arithmetic);
36 @@ -560,8 +560,8 @@ arithmetic_expansion
37 process_substitution
38 : (dir=LESS_THAN|dir=GREATER_THAN)LPAREN clist BLANK* RPAREN -> ^(PROCESS_SUBSTITUTION $dir clist);
39 //the biggie: functions
40 -function: FUNCTION BLANK+ function_name ((BLANK* parens wspace*)|wspace) compound_command redirect* -> ^(FUNCTION ^(STRING function_name) compound_command redirect*)
41 - | function_name BLANK* parens wspace* compound_command redirect* -> ^(FUNCTION["function"] ^(STRING function_name) compound_command redirect*);
42 +function: FUNCTION BLANK+ function_name ((BLANK* parens wspace*)|wspace) compound_command -> ^(FUNCTION ^(STRING function_name) compound_command)
43 + | function_name BLANK* parens wspace* compound_command -> ^(FUNCTION["function"] ^(STRING function_name) compound_command);
44 //http://article.gmane.org/gmane.comp.shells.bash.bugs/16424
45 //the rules from bash 3.2 general.c:
46 //Make sure that WORD is a valid shell identifier, i.e.
47
48 diff --git a/bashast/gunit/function.gunit b/bashast/gunit/function.gunit
49 index 642318e..6ee6c68 100644
50 --- a/bashast/gunit/function.gunit
51 +++ b/bashast/gunit/function.gunit
52 @@ -32,11 +32,11 @@ function:
53 "foo() { :; }" -> (function (STRING foo) (CURRENT_SHELL (LIST (COMMAND (STRING :)))))
54 "foo(){ :; }" -> (function (STRING foo) (CURRENT_SHELL (LIST (COMMAND (STRING :)))))
55
56 -"function quit { exit; } > /dev/null" -> (function (STRING quit) (CURRENT_SHELL (LIST (COMMAND (STRING exit)))) (REDIR > (STRING / dev / null)))
57 +"function quit { exit; } > /dev/null" -> (function (STRING quit) (CURRENT_SHELL (LIST (COMMAND (STRING exit))) (REDIR > (STRING / dev / null))))
58 "function quit {
59 # comment
60 - exit; } > /dev/null" -> (function (STRING quit) (CURRENT_SHELL (LIST (COMMAND (STRING exit)))) (REDIR > (STRING / dev / null)))
61 -"function help { echo hi; } 2> /dev/null" -> (function (STRING help) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING hi)))) (REDIR 2 > (STRING / dev / null)))
62 + exit; } > /dev/null" -> (function (STRING quit) (CURRENT_SHELL (LIST (COMMAND (STRING exit))) (REDIR > (STRING / dev / null))))
63 +"function help { echo hi; } 2> /dev/null" -> (function (STRING help) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING hi))) (REDIR 2 > (STRING / dev / null))))
64 "function help { echo 3; } 2> /dev/null > output" OK
65 "xorg-2_reconf_source() { :; }" -> (function (STRING xorg - 2 _reconf_source) (CURRENT_SHELL (LIST (COMMAND (STRING :)))))
66
67
68 diff --git a/bashast/gunit/list.gunit b/bashast/gunit/list.gunit
69 index 76c46b2..dcb2754 100644
70 --- a/bashast/gunit/list.gunit
71 +++ b/bashast/gunit/list.gunit
72 @@ -41,3 +41,5 @@ echo \"a b\"" -> (LIST (VARIABLE_DEFINITIONS (= a (STRING asdf))) (VARIABLE_DEFI
73 "FOO='bar' ;" -> (LIST (VARIABLE_DEFINITIONS (= FOO (STRING (SINGLE_QUOTED_STRING bar)))))
74 "true;
75 true" -> (LIST (COMMAND (STRING true)) (COMMAND (STRING true)))
76 +"(echo hi > /dev/null) >> 1" -> (LIST (SUBSHELL (LIST (COMMAND (STRING echo) (STRING hi) (REDIR > (STRING / dev / null)))) (REDIR >> 1)))
77 +"{ echo hi > /dev/null; } >> 1" -> (LIST (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING hi) (REDIR > (STRING / dev / null)))) (REDIR >> 1)))