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

Re: ignore globs that do not match



On Mon, 14 Jun 2004, Eric Smith wrote:

> Thomas Köhler said:
> > mpg() {
> >     local arg
> >     local l
> >     for arg ; do l="*$arg* $l" ; done
> >     eval mpg321 $l
> > }
> > 
> 
> Nice!

Almost equivalent to, but more wordy than, my *${^@}* solution.  The only
difference is that e.g.:

	mpg 'd*n'

(note quotes) evals "mpg321 *d*n*" and therefore expands the middle "*"
as well.  It wasn't clear you wanted those semantics.

> ("setopt cshnullglob" does not seem to work.)

That would be the way.  Works when I try it, with either formulation of
the function.

> $ mpg dylan gibberish crespo

Are you sure there are no globbing characters in the gibberish?  The
setopt will only apply inside the function, e.g. if you say

$ mpg foo*bar

then the shell first attempts to glob foo*bar and either gets "no match"  
or calls the mpg function with the results as arguments.

Perhaps what you're after is something like:

	mpg_glob() { mpg321 *${~^@}* }
	alias mpg='noglob mpg_glob'



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