I am trying to write a shell script that will have makemultiple targets on several different paths. I will give a list of paths separated by spaces, and a list of goals separated by spaces, and the script will be make DESTDIR=$path $targetfor each pair of paths and goals. In Python, my script would look something like this:
for path, target in zip(paths, targets):
exec_shell_command('make DESTDIR=' + path + ' ' + target)
However, this is my current shell script:
#! /bin/bash
packages=$1
targets=$2
target=
set_target_number () {
number=$1
counter=0
for temp_target in $targets; do
if [[ $counter -eq $number ]]; then
target=$temp_target
fi
counter=`expr $counter + 1`
done
}
package_num=0
for package in $packages; do
package_fs="debian/tmp/$package"
set_target_number $package_num
echo "mkdir -p $package_fs"
echo "make DESTDIR=$package_fs $target"
package_num=`expr $package_num + 1`
done
Is there a Unix tool equivalent to a Python zip function function or an easier way to get an item from a list, separated by a space, by its index? Thank.
source
share