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

Re: Would this (o) be very difficult to add?



    Hi Bart and zsh workers :))

 * DervishD <raul@xxxxxxxxxxxx> dixit:
>  * Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> dixit:
> > }     Sometimes we want to do globbing and sort the output randomly:
> > } when generating playlists, when generating image slideshows, etc...
> > Try this:
> > 	print -lP *(e:'REPLY=%0(l..$RANDOM)"$REPLY"':)
>     Very clever, I'd never have thought about something like that...

    This solution has worked great for generating, for example, a
file containing the names of the files in random order. The problem
is that I cannot use this in a command: command $(print -lP...)
results in 'command file name 1 file name 2', unquoted :((( Strictly
speaking, characters like '[' are quoted, but spaces arent, and the
names which I want to order randomly usually contain spaces.

    I've tried something like 'array=($(print -lP...))', but since
the expansion has spaces unquoted, the elements of the array end up
being 'file', 'name', '2', 'file', 'name', '1', and so on.

    How can I get the result of the 'e' glob qualifier quoted, so I
can use command $(print -lP...) and get a working command?

    Thanks a lot :))

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/



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