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

Re: Getting rid of temporaries...



On Thu, Sep 11, 2003 at 01:06:23AM +0000, Bart Schaefer wrote:

> This suggestion is on the right track, but it's not equivalent to Raul's
> original one, because your first assignment may match names that do not
> match *.<00-99>.jpg, which won't be modified by the second assignment.

Neither does his original; he was selecting all files, too.  But yes,
you'd probably want to use a more specific globbing pattern.

> } will do what you want.  The "typeset -U" makes $array discard duplicate
> } elements, but that requires the reassignment once the dups are gone
> 
> I'm not sure what you mean by "requires the reassignment once the dups
> are gone".  You have to strip the suffixes before zsh can tell what the
> duplicates are.

That's what I meant; I was concentrating on the two-step process and
muddled the rest of it.

> } The "^" turns on rcexpandparam for the expansion of $array, which means
> } that, as an array, each element is modified.
> 
> That's not what rcexpandparam means.

Yup.  It's gotten stuck in my mind that it's needed for situations other
than just concatenation, including anything that needs to operate on
every array element.  That's obviously wrong.

> So we end up with, perhaps:
> 
>     typeset -U array
>     array=( *.<00-99>.jpg(e['REPLY=${REPLY%.??.jpg}']) )
>     print -l $array

Or

    array=( *.<00-99>.jpg(e['REPLY=${REPLY%.??.jpg}']) )
    print -l ${(u)array}

which was more what I was hoping for.

There's still no way of expanding a glob inside ${}, short of ${$(echo *)},
is there?

Danek



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