Mark Brown wrote:
On 2/19/08, Martin Sebor <[EMAIL PROTECTED]> wrote:
Travis Vitek wrote:
> sebor-2 wrote:
>> + // weirdly-formed brace expansions -- fixed in post-bash-3.1
>> + TEST ("a-{b{d,e}}-c", "a-{bd}-c a-{be}-c");
>>
>
> I don't understand how this could be interpreted as valid brace expansion at
> all. The body of the expansion is '{b{d,e}}'. Paragraph 5 [and paragraph 1
> for that matter] require a correctly-formed brace expansion have unquoted
> [unescaped?] opening and closing braces, and at least one unquoted comma or
> a valid sequence expression. The body does not meet either of these
> requirements, so it must be invalid.
>
The C-Shell that had brace expansion long before Bash did outputs
a-bd-c a-be-c as Martin expects. It doesn't require a comma at all.
Actually, the expected output (expected by the Bash test suite, not
necessarily by me :) is "a-{bd}-c a-{be}-c"
But it looks like the difference is in how each shell treats what
I called the "brace list", i.e., the text delimited by the pair of
braces: bash requires a comma while csh does not. I.e., bash doesn't
treat "{abc}" as a brace expression while csh expands it to "abc",
and so bash treats "a-{b{d,e}}-c" as a single brace list "{d,e}"
with a preamble of "a-{b" and a postfix of "}-c"
IMO, the C shell behavior makes more sense. I don't see how treating
single-element brace lists (i.e., "{abc}" vs "{abc,def}" as errors
is useful.
The C shell behavior also happens to correspond to the grammar I
proposed earlier:
string ::= <brace-expr> | [ <chars> ]
brace-expr ::= <string> '{' <brace-list> '}' <string> | <string>
brace-list ::= <string> ',' <brace-list> | <string>
chars ::= <pcs-char> <string> | <pcs-char>
pcs-char ::= character in the Portable Character Set
That being said, I downloaded and installed zsh which also supports
brace expansion. It behaves the same way as Bash, i.e., it requires
at least one comma to recognize a brace expression. Consequently, it
expands "a-{b{d,e}}-c" the same way Bash does, i.e., it produces
"a-{bd}-c a-{be}-c"
>
>
> sebor-2 wrote:
>> + TEST ("a-{bdef-{g,i}-c", "a-{bdef-g-c a-{bdef-i-c");
>>
>
> Again, this does not seem correct according to the requirements of paragraph
> 5 [and 1].
The C-Shell complains about a missing brace in this expression.
Here, Zsh produces the output expected by the Bash test suite, i.e.,
"a-{bdef-g-c a-{bdef-i-c"
But I think this one is just too weird and should be left unspecified.
Martin