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

Fun with zsh (Re: Associative array ordering (Re: Example function))



On Feb 2,  9:01am, Sven Wischnowsky wrote:
} Subject: Re: Associative array ordering and selective unset (Re: Example f
}
} Bart Schaefer wrote:
} 
} > Now change the assignment a little:
} > 
} >         map=('*.(gz|Z)' ': 1; zcat
} >              '*.bz2' ': 2; bzip2 -dc'
} >              '*.bz' ': 3; bzip -dc'
} >              '*' ': 4; <')
} 
} Hmm, I like this. For bigger arrays one would have to use `01' and so
} on, but this should be acceptible.

Somewhat off-topic, but how about this trick?  (Where map is a plain array
this time.)

    map=(
    	'(*.(gz|Z))	zcat' 
	'(*.bz2)	bzip2 -dc'
	'(*.bz)		bzip -dc'
	'(*)		<'
	)
    eval 'for i do case $i in' ${(j( $i;; ))map} '$i;; esac done'

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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