From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Fri, 5 Feb 1999 18:48:53 -0500 From: Sweth Chandramouli To: zsh-users@math.gatech.edu Subject: Globbing in a function (was Re: globbing for links in pathnames) Message-ID: <19990205184853.A24198@astaroth.nit.gwu.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailing-List: 2108 On Thu, Feb 04, 1999 at 09:07:55PM -0800, Bart Schaefer wrote: > On Feb 4, 11:22pm, Sweth Chandramouli wrote: > } so it should end up something like the following: > } > } x=(pkgs/*(@)) ; ls -d ${^x}/man(/) > > The reason I used the eval was to avoid having x remain set after the > command completes. `x=(*(@)) eval ...` will unset x again at the end > of the eval, and won't destroy any existing value of x. i have a function that i use to link executables from where i normally install them to (usually /opt/wherever) to /usr/local/bin. i was trying to rewrite it using this sort of format (rather than invoking find, as i was doing before), but am running afoul of something that i can't quite figure out. the i've hacked out some stuff at the beginning (to allow me to pass it options) for the sake of clarity; the interesting part is this: (astaroth)~/.zfunc: BINLIST=(*(*)) ; echo $BINLIST ; unset BINLIST binlink cwhois gpid mck newm newterm nobrs perf xbuffy xt xtitle (astaroth)~/.zfunc: which binlink binlink () { BINLIST=($1(*)) eval 'for BIN in ${=BINLIST} ; do ln -s ${BIN} /usr/local/bin ; done' } (astaroth)~/.zfunc: binlink \* zsh: no matches found: *(*) putting an echo in at the end confirms that BINLIST in the function is, when binlink is given an escaped asterisk as its argument, being set to (*(*)); since parameter expansion occurs before filename generation, why doesn't setting BINLIST to that value in the function do the same thing that it does from the command line? -- sweth. -- Sweth Chandramouli IS Coordinator, The George Washington University / (202) 994 - 8521 (V) / (202) 994 - 0458 (F) *