Subject: Re: Bourne shell question
To: Jeremy C. Reed <reed@reedmedia.net>
From: Daniel Eggert <danieleggert@mac.com>
List: netbsd-help
Date: 12/19/2002 18:44:13
On torsdag, dec 19, 2002, at 17:23 Europe/Copenhagen, Jeremy C. Reed 
wrote:

> On Thu, 19 Dec 2002, Daniel Eggert wrote:
>
>> In my shell script I have two variables. Something like this:
>> 	partitions="ld0a ld0b ld1a"
>> 	paths="/a /b /c"
>> Now I want to loop through these and access
>> 	'ld0a' with '/a'
>> 	'ld0b' with '/b'
>> 	'ld1a' with '/c'
>> Is there any easy / clever way to do this in /bin/sh?
>
> Use /bin/ksh (because it supports arrays).
>
> set -A partitions ld0a ld0b ld1a
> set -A paths /a /b /c
>
> index=0
> while [ $index -lt ${#partitions[@]} ] ; do
>   echo \'${partitions[$index]}\' with \'${paths[$index]}\'
>   let index=index+1
> done

Thanks. I want to stick to /bin/sh, though, in order to be able to run 
it during install.

Daniel