From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Bart Schaefer" Message-Id: <990205091428.ZM23509@candle.brasslantern.com> Date: Fri, 5 Feb 1999 09:14:28 -0800 To: zsh-users@math.gatech.edu Subject: Re: globbing for links in pathnames MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailing-List: 2105 On Feb 5, 2:24pm, Andrew Gallagher wrote: } Subject: Re: globbing for links in pathnames } } Phil Pennock wrote: } } > Okay, why do neither the second nor third ones here work "as expected"? } > } > % print -l ${(A)~x::=pkgs/*(@)} } > pkgs/bar } > pkgs/foo } > % print -l ${(A)^~x::=pkgs/*(@)}/man } > pkgs/*(@)/man } > % print -l ${^${(A)~x::=pkgs/*(@)}}/man } > pkgs/*(@)/man } > % } } I can't tell you "why" this happens, but it seems that "how" it happens is } that the "/man" is being appended to the result of the parameter expansion } before globbing takes place. Evidently, when the ~ is processed it sets a } flag which allows globbing to happen further down the line, rather than } forcing globbing to happen at that point. Mostly correct. Normally zsh "tokenizes" the command line as it is parsed. '*' is changed into a character represented internally by the constant Star, '(' becomes Inpar, '$' becomes String, etc. (If the tokens themselves appear in the input, they become a magic two-byte sequence.) Globbing is invoked when the Star token (among others) is seen when the input is re-scanned after other expansions; the order in which expansions occur is in the manual. Also normally, the parameter expansion code DOES NOT tokenize the string that it returns, so Star et al. don't appear and no globbing happens. What ~ does is cause the string to be tokenized. That doesn't affect the order of expansions, so globbing is now enabled but doesn't happen until later. (Maybe that's more than zsh-users want to know ....) -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com