Why wait in this script is not executed after all subshells?
7
votes
1
answer
762
views
In this script, that pulls all git repositories:
#!/bin/bash
find / -type d -name .git 2>/dev/null |
while read gitFolder; do
if [[ $gitFolder == *"/Temp/"* ]]; then
continue;
fi
if [[ $gitFolder == *"/Trash/"* ]]; then
continue;
fi
if [[ $gitFolder == *"/opt/"* ]]; then
continue;
fi
parent=$(dirname $gitFolder);
echo "";
echo $parent;
(git -C $parent pull && echo "Got $parent") &
done
wait
echo "Got all"
the wait
does not wait for all git pull
subshells.
Why is it so and how can I fix it?
Asked by Saeed Neamati
(841 rep)
Jan 27, 2022, 04:53 PM
Last activity: Jan 28, 2022, 04:24 PM
Last activity: Jan 28, 2022, 04:24 PM