I am trying to learn loops and array manipulation in zsh
.
Say I have two arrays in zsh with the same unknown # of elements and each of them containing a list of paths, e.g.
LOCAL_ARRAY=($LOCAL_PATH_1 $LOCAL_PATH_2 $LOCAL_PATH_3)
REMOTE_ARRAY=($REMOTE_PATH_1 $REMOTE_PATH_2 $REMOTE_PATH_3)
I would like to iterate through both arrays simultaneously with a common index, so that I can do something like:
cd $LOCAL_PATH_i
hg pull $REMOTE_PATH_i
in each iteration. How can I do this in zsh?
Also, I have searched for loop control and arrays in the zsh documentation but had little success. Is there a good tutorial that introduces the basics of loops, arrays, etc. in zsh? Something for people with little bash or shell-scripting experience but with a background in programming?