Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: On the quoting of braces



On 2011-12-07, Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> On Tue, 06 Dec 2011 23:16:35 +0100
> Christian Neukirchen <chneukirchen@xxxxxxxxx> wrote:
>> comparing different shells, I noticed zsh is overly careful for unquoted
>> braces:
>> zsh% echo { foo,bar }
>> zsh: parse error near `}'
>>
>> Why does this error appear?
>
> zsh allows a "}" to appear other than in command position at the end of
> a shell construct or a function definition:
>
> { echo }
>
> and
>
> fn() { echo }
>
> aren't complete statements in other shells.  So this means a "}" is
> treated as special everywhere on the command line.
>
>> The only way to disable it seems to be
>> IGNORE_BRACES, which completely disables (the much used) brace expansion.
>
> Yes, this is really a different thing, since it doesn't involve a brace
> on its own as an argument.  They shouldn't really be tied together.  In
> fact, it looks like this additional effect of IGNORE_BRACES isn't even
> documented.

Under "RESERVED WORDS" we say:
       Additionally, `}' is recognized in any position if the
IGNORE_BRACES option
       is not set.

So maybe we should change that section too.

[...]
> Index: Doc/Zsh/options.yo
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
> retrieving revision 1.103
> diff -p -u -r1.103 options.yo
> --- Doc/Zsh/options.yo	18 May 2011 01:54:36 -0000	1.103
> +++ Doc/Zsh/options.yo	7 Dec 2011 20:28:41 -0000
> @@ -548,7 +548,32 @@ cindex(disabling brace expansion)
>  cindex(brace expansion, disabling)
>  cindex(expansion, brace, disabling)
>  item(tt(IGNORE_BRACES) (tt(-I)) <S>)(
> -Do not perform brace expansion.
> +Do not perform brace expansion.  For historical reasons this
> +also includes the effect of the tt(IGNORE_CLOSE_BRACES) option.
> +)
> +pindex(IGNORE_CLOSE_BRACES)
> +pindex(NO_IGNORE_CLOSE_BRACES)
> +pindex(IGNORECLOSEBRACES)
> +pindex(NOIGNORECLOSEBRACES)
> +item(tt(IGNORE_CLOSE_BRACES))(
> +When neither this option no tt(IGNORE_BRACES) is set, a sole
                            ^^ nor

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author