forked from decal/werdlists
-
Notifications
You must be signed in to change notification settings - Fork 2
/
missing-index-entries
executable file
·75 lines (53 loc) · 1.66 KB
/
missing-index-entries
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash
#
# missing-index-entries v0.9b
#
# Look for folders without an README.md file or are missing entries from it
#
# Written By: Derek Callaway [decal {AT} sdf {D0T} org]
# Last Modified: Sat Nov 12 13:08:03 EST 2016
# Tested On: Kali GNU/Linux Rolling
#
declare -l acurrent_dirname="`basename $(pwd)`"
echo "${reset}"
if [[ $acurrent_dirname == 'scripts' ]]
then cd ..
else
[[ $acurrent_dirname == 'bin' ]] && cd ..
fi
if [ ! -d scripts ]
then echo -e "${orangeb}${blackf}***${reset} ${boldon}$0${boldoff} MUST be executed as ${italicson}./script${italicsoff} or ${italicson}bin/script${italicsoff}"
exit 1
fi
[ -f scripts/shared/colors ] && source -- scripts/shared/colors
declare -a wldirs=( `find . -maxdepth 1 -type d -not -name '.*' -print` )
for adir in "${wldirs[@]}"
do declare xdir=$(basename $adir)
cd -- "${xdir}"
declare -a wlfiles=( `ls -1 *.* | cut -d '.' -f1 | egrep -iv '^INDEX$'` )
[[ $? != 0 ]] && continue
declare -a listfiles_missing=( )
for afil in "${wlfiles[@]}"
do #
if [ ! -s README.md ]
then rm -f README.md
touch README.md
for anam in ${wlfiles[*]}
do echo -e "${anam}: " >> README.md
done
fi
declare output=$( egrep -i "^${afil}:" README.md | egrep -iv '^INDEX\.md$' )
[[ $output == "" ]] && listfiles_missing+=( $afil )
done
if [ ${#listfiles_missing[@]} -ne 0 ]
then echo -ne "${redb}${blackf}${xdir}${boldon}:${reset} "
echo -ne "${purplef}${blackb} ${listfiles_missing[*]} "
else
echo -ne "${blueb}${blackf}${xdir}"
fi
echo -e "${reset}"
# echo ${afil} >> README.md
cd ..
done
echo -e "${reset}"
exit 0