if [[ $1 == "all" ]] ; then
shift
if [[ $# -eq 0 ]] ; then
- exec r forall -c 'r rb all .'
+ exec r forall -p -c 'r rb all .'
fi
branches=$(g b | awk '
[[ -z ${branches} ]] && exit 0
eval $(bash-colors --env)
- echo "${GOOD}### ${PWD}${NORMAL}"
+ #echo "${GOOD}### ${PWD}${NORMAL}"
for b in ${branches} ; do
echo " ${HILITE}### $b${NORMAL}"
g co -q $b || exit 1
echo "pushing projects from ${root}"
- pids=()
+ pipe=$(mktemp)
+ rm -f "${pipe}"
+ mkfifo "${pipe}"
+ exec {ctlfd}<>"${pipe}"
+ rm -f "${pipe}"
+ jobs=0
+
rlist=$(r list)
tcnt=$(echo "${rlist}" | wc -l)
cnt=1
${#tcnt} $((cnt++)) ${tcnt} $(( cnt * 100 / tcnt )) ${proj}
src="${sync_branch}"
g l -1 ${src} >& /dev/null || src=
- ( g push --force ${remote}/${proj} ${src}:refs/sandbox/${USER}/${sync_branch} >/dev/null ) &
+ (
+ g push --force ${remote}/${proj} ${src}:refs/sandbox/${USER}/${sync_branch} >/dev/null
+ echo ${BASHPID} $? >&${ctlfd}
+ ) &
# ssh servers do not like it when you hammer them :)
# Received disconnect from 74.125.248.80: 7: Too many concurrent connections
# fatal: The remote end hung up unexpectedly
- pids+=( $! )
- if [[ ${#pids[@]} -eq 20 ]] ; then
- wait ${pids[@]:0:3}
- pids=( ${pids[@]:3} )
+ : $(( ++jobs ))
+ if [[ ${jobs} -eq 16 ]] ; then
+ read -r -u ${ctlfd} pid ret
+ : $(( --jobs ))
fi
- done <<<"$(r list)"
+ done < <(r list)
wait
exit 0