我用我有限的bash脚本知识制作了一个快速的小脚本。它有一个带有参数的标志的函数。
像这样:switchall -b branchesIwantToCheckOut
# Git switch all repos to a given branch.
switchall() {
# Reset OPTIND so we can call this function multiple times.
local OPTIND
while getopts "b:" OPTION; do
case $OPTION in
b)
echo "Switching all GIT repo's to: $OPTARG"
for d in ~/git/*/
do
( cd $d && git checkout $OPTARG )
done
;;
esac
done
}
这个问题在于,无论何时运行它,我的CPU使用量都会大幅增加到我多次使用后查看顶部时达到70%的程度。我猜我以某种方式搞砸了循环,但我不知道究竟是怎么回事。
如果有人可以快速循环来帮助我,我会非常感激。