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

Re: ${(kv)foo[bar]}



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sunday 03 April 2005 21:49, Bart Schaefer wrote:
>
> Isn't that a rather silly way to do it in any case?  You don't need the
> subscript flags at all.  Why not
>
>       pkgs=( $(urpmq --list
>                 --media ${opt_args[--media]}
>                 --searchmedia ${opt_args[--searchmedia]}
>                 2> /dev/null
>            )
>

because it breaks if no --media is given on command line. My example would 
have worked in both cases.

> If for some reason you want to be deliberately obscure, you can force it
> with:
>
>       pkgs=( $(urpmq --list
>                 ${(kv)opt_args[(i)--media]}
>                 ${(kv)opt_args[(i)--searchmedia]}
>                 2> /dev/null
>            )
>

OK, in my case it turned out I needed something more elaborate anyway but 
thank's for the idea, I'll keep it in mind :)

Although it is rather hard to understand why ${(kv)opt_args[(i)--media]} 
should work and ${(kv)opt_args[--media]} not.

- -andrey
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFCUC9JR6LMutpd94wRAimbAJ9bmX5OGhZAWmDgJREeHrkyFhuDNACdE7yU
c2ROqzFKiCBtUa0aoJaKs9s=
=EvN6
-----END PGP SIGNATURE-----



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