From a8118623d11f2c540825821d29d1737b1f714c8b Mon Sep 17 00:00:00 2001 From: Zihao Yu Date: Sat, 26 Aug 2017 11:50:37 +0800 Subject: [PATCH] init.sh: add retry --- init.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/init.sh b/init.sh index 5be7b22..b72197c 100644 --- a/init.sh +++ b/init.sh @@ -3,16 +3,18 @@ log="" function init() { - if test -d $1; then + if [ -d $1 ]; then echo "$1 is already initialized, exiting..." return fi - git clone -b ics2017 https://github.com/NJU-ProjectN/$1.git + while [ ! -d $1 ]; do + git clone -b ics2017 https://github.com/NJU-ProjectN/$1.git + done log="$log$1 `cd $1 && git log --oneline --no-abbrev-commit -n1`"$'\n' rm -rf $1/.git - if test $2; then + if [ $2 ] ; then sed -i -e "/^export $2=.*/d" ~/.bashrc echo "export $2=`readlink -e $1`" >> ~/.bashrc fi