Git 使用 bash 脚本的镜像卡在 3 for 循环中

Git mirroring with bash scripting stuck in 3 for loop

git1 ---> git3 (必须使用path1)

git2 ---> git4 (必须使用path2)

git1 无法克隆到 git4,或者 git2 无法克隆到 git3.Everytime 它应该像上面那样工作 way.Script 开始使用 git1 它必须继续并保持下一个值方式 git1-git3-path1,当第一个循环完成时它应该开始第二个像 git2-git4-path2

我的划痕

A_sources=(git1 git2)
B_destinations=(git3 git4)
C_filename=(path1 path2)
workdir="/home/"




for A in "${A_sources[@]}"; do
    for B in "${B_destinations[@]}"; do
        for C in "${C_filename[@]}"; do
            git clone --mirror "${A}"
            cd "${workdir}/${C}"9
            git remote set-url --push origin "${B}"
        done
    done
done

一个索引循环而不是元素的三个嵌套循环,例如

# ensure the size are equal
(( ${#A_sources[@]} == ${#B_destinations[@]} && ${#B_destinations[@]} == ${#C_filename[@]})) || { echo "arrays sizes are not equals"; exit 1;}

for ((i=0;i<${#A_sources[@]};i+=1)); do
    git clone --mirror "${A_sources[i]}"
    cd "${workdir}/${C_filename[i]}"9
    git remote set-url --push origin "${B_destinations[i]}"
done