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

Re: order of processing in brace expansion



On May 2,  4:28pm, Peter Stephenson wrote:
}
} This is rather hairy.  The obvious fix is to tokenize braces, too.  This
} seems to do the trick, but the change of behaviour is now much more
} obvious.  We probably ought to make it either all or nothing.  Bash doesn't
} expand braces that result from parameters (probably due to the ordering of
} expansions).  Any suggestions?

I'd prefer that the code and the doc agree with on another.  Doc:

${~SPEC}
     Turn on the GLOB_SUBST option for the evaluation of SPEC; if the
     `~' is doubled, turn it off.  When this option is set, the string
     resulting from the expansion will be interpreted as a pattern
     anywhere that is possible, such as in filename expansion and
     filename generation and pattern-matching contexts ...

GLOB_SUBST <C> <K> <S>
     Treat any characters resulting from parameter expansion as being
     eligible for file expansion and filename generation, and any
     characters resulting from command substitution as being eligible
     for filename generation.

There's no mention of brace expansion there anywhere, and braces are not
expanded in "a pattern" for most senses of "pattern" elsewhere in the doc;
on the other hand, for command substitutions, it's not even supposed to
tokenize a leading `~' or `=', which it obviously does anyway:

zsh% echo $(echo '~')
~
zsh% (setopt glob_subst; echo $(echo '~'))
/home/schaefer

[That latter is definitely a SH_FILE_EXPANSION interaction with GLOB_SUBST;
the GLOB_SUBST doc is describing the case where SH_FILE_EXPANSION is set:

zsh% (setopt glob_subst sh_file_expansion; echo $(echo '~')) 
~

So we have some doc to fix even if we don't change comma/brace behavior.]

As of this moment, my leaning in the "all or nothing" category is towards
"nothing", particularly because of the possibility of breaking sh/bash
compatibility (note that GLOB_SUBST is set by default for sh/ksh emulation).

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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