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: Sun, 17 Apr 2011 10:59:52
Message-Id: b680da3520a8fa589848a9c205b52688f3ca13e3.betelgeuse@gentoo
1 commit: b680da3520a8fa589848a9c205b52688f3ca13e3
2 Author: Petteri Räty <petsku <AT> petteriraty <DOT> eu>
3 AuthorDate: Sat Apr 16 18:11:54 2011 +0000
4 Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
5 CommitDate: Sun Apr 17 10:57:04 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=b680da35
7
8 Parser: function name rules from bash sources
9
10 Relax the function name rules so that now again most eclasses parse. The
11 implemention is done using negation so hopefully it doesn't break that
12 easily.
13
14 ---
15 bashast/bashast.g | 7 +++++--
16 bashast/gunit/function.gunit | 8 ++++++++
17 2 files changed, 13 insertions(+), 2 deletions(-)
18
19 diff --git a/bashast/bashast.g b/bashast/bashast.g
20 index 3b1e4ed..745b1ff 100644
21 --- a/bashast/bashast.g
22 +++ b/bashast/bashast.g
23 @@ -523,9 +523,12 @@ process_substitution
24 function: FUNCTION BLANK+ function_name (BLANK* parens)? wspace compound_command redirect* -> ^(FUNCTION ^(STRING function_name) compound_command redirect*)
25 | function_name BLANK* parens wspace compound_command redirect* -> ^(FUNCTION["function"] ^(STRING function_name) compound_command redirect*);
26 //http://article.gmane.org/gmane.comp.shells.bash.bugs/16424
27 -//the documented set is stricter but we need to have at least what's used in Gentoo
28 +//the rules from bash 3.2 general.c:
29 +//Make sure that WORD is a valid shell identifier, i.e.
30 +//does not contain a dollar sign, nor is quoted in any way. Nor
31 +//does it consist of all digits.
32 function_name
33 - : (MINUS|DIGIT|name)+;
34 + : (NUMBER|DIGIT)? ~(DOLLAR|SQUOTE|DQUOTE|LPAREN|RPAREN|BLANK|EOL|NUMBER|DIGIT) ~(DOLLAR|SQUOTE|DQUOTE|LPAREN|RPAREN|BLANK|EOL)*;
35 parens : LPAREN BLANK* RPAREN;
36 name : NAME
37 | LETTER
38
39 diff --git a/bashast/gunit/function.gunit b/bashast/gunit/function.gunit
40 index c22821a..a474273 100644
41 --- a/bashast/gunit/function.gunit
42 +++ b/bashast/gunit/function.gunit
43 @@ -37,3 +37,11 @@ function:
44 "function help { echo hi; } 2> /dev/null" -> (function (STRING help) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING hi)))) (REDIR 2 > (STRING / dev / null)))
45 "function help { echo 3; } 2> /dev/null > output" OK
46 "xorg-2_reconf_source() { :; }" -> (function (STRING xorg - 2 _reconf_source) (CURRENT_SHELL (LIST (COMMAND (STRING :)))))
47 +
48 +function_name:
49 +"xemacs-packages_src_unpack" OK
50 +"while" OK
51 +"aa'bb" FAIL
52 +"a\"" FAIL
53 +"333" FAIL
54 +"aa$aa" FAIL