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

Re: globbing with interposition



On Apr 19,  9:21am, Eric Smith wrote:
}
} mutt eric -a fotos* -s "all images attached" </dev/null

It would be really nice if this worked:

    mutt eric fotos*(e:'reply=(-a $REPLY)':) -s "all images attached"

However, there's no way tell zsh NOT to sort the results of globbing.
I mention this so that I can propose a new key for the 'o' and 'O' glob
qualifiers, a key meaning "don't sort this glob at all."

For bizarre reasons I don't immediately understand, the following does
what you want, but probably isn't guaranteed to keep working in future
releases:

    mutt eric fotos*(e:'reply=($REPLY -a)':od) -s "all images attached"

(and no, using Od instead of od doesn't change anything).  That is, the
'od' qualifier prevents zsh from sorting the full list, but for some
reason zsh reverses the $reply array; e.g.:

    touch frobnitz flobozz
    print f*z(e:'reply=(1 2 $REPLY 3 4)':od)

will output something like

    4 3 flobozz 2 1 4 3 frobnitz 2 1

This happens for 'oa', 'oc', and 'om' as well.

On Apr 19, 10:22am, J wrote:
} Subject: Re: globbing with interposition
}
} a=(fotos*) mutt eric '-a '${^a} -s "all images attached" </dev/null

That doesn't work because the order of assignment and expansion is not
what you expect.  That is, the ${^a} is expanded at parse time, but
the assignment prefixes are handled at execute time.  You'd have to do

a=(fotos*) eval 'mutt eric "-a "${^a} -s "all images attached" </dev/null'

but that suffers from the same problems as this:

} mutt eric '-a '${^$(print *)} -s "all images attached" </dev/null

That one fails if there are spaces in any of the file names, and on
top of that the space character after the -a is quoted, so mutt will
see '-a somefile' all as one string, not as '-a' and 'somefile'.

The only sure-fire way I can see to do it (without a loop similar to
Raúl's first suggestion) is like this:

    a=()
    : fotos*(e:'a+=(-a $REPLY)':)
    mutt eric $a -s "all images attached" </dev/null



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