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

[Review Request] Arrays and their usage



Hi *,

I always feel a little unsure around arrays in zsh. I've currently used the following:

   local pkgs=( `makepkg --printsrcinfo | \
sed -n -e 's/pkgname = \(.*\)$/\1/p'` )
   pkgs=(${pkgs/#/"$DATABASE/"})
   sudo pacman -S $pkgs

Intention: Generate a list of packages, prepend "$DATABASE/", and pass each modified package as a separate argument to pacman.

Question: Is this the correct/zshonic way of doing this?
I personally find the change of behavior by adding ( ) too easy to overlook. Is there an alternative with ${(...)}?

Thanks,
René




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