Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Sorting file names randomly
- X-seq: zsh-users 9141
- From: DervishD <zsh@xxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Sorting file names randomly
- Date: Sun, 24 Jul 2005 10:37:32 +0200
- Cc: Zsh Users <zsh-users@xxxxxxxxxx>
- In-reply-to: <1050724064415.ZM20425@xxxxxxxxxxxxxxxxxxxxxxx>
- Mail-followup-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Zsh Users <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Organization: DervishD
- References: <20050723194240.GA32416@DervishD> <20050723212657.GA744@DervishD> <1050724064415.ZM20425@xxxxxxxxxxxxxxxxxxxxxxx>
Hi Bart :)
* Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> dixit:
> On Jul 23, 9:42pm, DervishD wrote:
> }
> } shuffle dir1/* dir2/* ...
> There's no reason to noglob and alias this. The space required to
> expand the glob on the command line is no worse than what you're
> doing inside the function anyway, and there aren't argument-size
> limits on calls to shell functions, only on external commands.
How about this?:
function shuffle () {
emulate -L zsh
setopt nullglob globdots rcexpandparam
RANDOM=`date +%s`
[[ $# -eq 0 ]] && set '*'
reply=()
reply=($*)
reply=($reply(e:'REPLY="${(l.5..0.)RANDOM} $REPLY"':))
reply=(${(o)reply})
reply=(${reply/#????? /})
print -l $reply
return 0
}
It does the globbing outside, and shuffles correctly. Any way of
making the 'reply' assignments shorter? Should I go definitely for a
'for' loop and an associative array?
Thanks a lot :)
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to...
Messages sorted by:
Reverse Date,
Date,
Thread,
Author