parse input fiile to array before provcessing

This commit is contained in:
Trevor Batley 2023-06-06 11:45:25 +10:00
parent f2b2c021f8
commit 0c2b8da54f

View File

@ -86,9 +86,10 @@ for param in $3 $4 $5 $6; do
fi
done
# Build array of parameters to cycle through
PARAMLIST=
if [ $PROCESSORG ] ; then
# cycle through the repos in the specified organisation
# get a list of repositories in the source organisation
# get a list of repositories in the source organisation and store in array of parameters
for page in {1..10} ; do
if [ $DEBUG ] ; then echo "getting page $page of repos from $GITEAHOST $PROCESSORG" ; fi
RESPONSE=$(curl -s -X 'GET' \
@ -105,19 +106,23 @@ if [ $PROCESSORG ] ; then
echo $RESPONSE | grep -oP '(?<="name":").+?(?=")' | while read repo; do
if [[ $NOISY || $REVIEW ]] ; then echo "$2 $repo $EXTRAPARAMS" ; fi
if [[ ! $REVIEW ]] ; then
if [[ $repo ]] ; then $2 $repo $EXTRAPARAMS ; fi
if [[ $repo ]] ; then $PARAMLIST+=$repo ; fi
fi
done
fi
done
else
# read through input file and run script using params from file
while read -r line
# load array of parameters from input file
while read -r line ; do $PARAMLIST+=$line ; done < $1
fi
# Cycle through array of parameters and execute script
for param in "${PARAMLIST[@]}"
do
if [[ $NOISY || $REVIEW ]] ; then echo "$2 $line $EXTRAPARAMS" ; fi
if [[ $NOISY || $REVIEW ]] ; then echo "$2 $param $EXTRAPARAMS" ; fi
if [[ ! $REVIEW ]] ; then
if [[ $line ]] ; then $2 $line $EXTRAPARAMS ; fi
fi
done < $1
if [[ $line ]] ; then $2 $param $EXTRAPARAMS ; fi
fi
done
exit 0