forked from decal/werdlists
-
Notifications
You must be signed in to change notification settings - Fork 2
/
files-vs-readme
executable file
·60 lines (43 loc) · 1.51 KB
/
files-vs-readme
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
#!/usr/bin/env bash
#
# files-vs-readme v1.0
#
# Compare files listed in each folder to those shown in its `README.md`
# This shows maintainers which files aren't listed in the folder index
#
# Written by: Derek Callaway [decal (AT) sdf (D0T) org]
# Last Modified: Wed Oct 26 13:48:05 EDT 2016
# Tested On: Kali GNU/Linux Rolling
#
WRDLS_PAGER='/bin/more'
[ ! -x "$WRDLS_PAGER" ] && WRDLS_PAGER="`which less`"
[ ! -x "$WRDLS_PAGER" ] && WRDLS_PAGER='/bin/cat'
export LESS='-R'
export WRDLS_PAGER
[ -f colors ] && source -- colors
# exit gracefully on error; be mindful of possibly malicious user function input
function errx_exit() {
local readonly emsg=$( errno -- $1 | tail -n +1 )
# redirect to STDERR_FILENO and close STDOUT_FILENO
declare -l -- astr="${blackf}${yellowb}$2"
(echo -e "${reset}${whitef}${boldon}:${reset} ${redf}${emsg}${reset}" 1>&2) <&1-
exit -- $1
}
[[ "$(realpath `pwd`)" =~ '/scripts' ]] && cd ..
LS=$( find . -maxdepth 1 -type d -not -iname '.*' -name '*-*' -print | egrep -v '^\./scripts$' )
[ $? -ne 0 ] && errx_exit "$?" "$_"
[[ "$PAGER" == "" ]] && export PAGER="$WRDLS_PAGER"
for d in $LS
do declare rpth="$(realpath $d)"
declare avar="$(basename $rpth)"
[[ "$avar" == "" ]] && continue
cd $avar
for f in $( ls -1 * | egrep -v '^README\.md$' )
do declare anam=$( echo $f | cut -d '.' -f1 )
echo -ne "${bluef}${avar}${boldon}:${boldoff}${reset} "
echo -ne "$(grep --color=ALWAYS -ia -- "${anam}" README.md)"
echo
done
cd ..
done <&2- | $PAGER
exit 0