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

Re: Getting rid of temporaries...



DervishD wrote:

> > Can do the unique with the `e' globbing flag but not without
> > temporaries or eval.
> 
>     How can I do using eval? Assume that I don't have the (u) flag...

Wasn't as easy as I thought. Thought I could do something like:

guniq() { eval "[[ -z ${~REPLY:r:r}.<${~REPLY:r:e}->.jpg(N[2]) ]]" }
print -l *.??.jpg(e:guniq:)

But eval insists on quoting the third word in what it runs so it does
  [[ -z 'foo.<28->.jpg(N[2])' ]]
which is no use.

The guniq() function there isn't necessary, it just makes quoting
easier.

You can do this though:

guniq() { [[ -z "$2" ]] }
print -l *.??.jpg(e['eval "guniq ${REPLY:r:r}.<${REPLY:r:e}->.jpg"']:r:r)

This solution needs the separate function and is in effect using $@ as
a temporary array though.

Oliver



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