-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathcheckout-readmes
More file actions
executable file
·39 lines (26 loc) · 902 Bytes
/
Copy pathcheckout-readmes
File metadata and controls
executable file
·39 lines (26 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
#
# Check each folder's `README.md` file out of the code repository in case they were
# mistakenly removed and/or corrupted during maintenance procedures..
#
read -t 2 -p "Are you sure you want to checkout each folder's README.md file from the repository (this should only be done if they were removed by mistake)? [y/N]: " ANSWER
[ "$ANSWER" -a "${ANSWER[0]}" != "y" -a "${ANSWER[0]}" != "Y" ] && exit 1
while [ ! -d .git ]
do cd ..
declare cdirname=$( basename `pwd` )
[[ $cdirname == 'GIT' ]] && exit 1
done
declare -a xdirnames=$( find . -maxdepth 1 -type d -not -name '.*' -print )
for d in ${xdirnames[*]}
do cd -- "`basename $d`"
[ $? -ne 0 ] && continue
[ -f README.md ] && mv -v README.md README.md.bak
git checkout README.md
if [ -f README.md ]
then rm -f README.md.bak
else
mv -v README.md.bak README.md
fi
cd ..
done
exit 0