forked from decal/werdlists
-
Notifications
You must be signed in to change notification settings - Fork 2
/
dirs-vs-index
executable file
·51 lines (36 loc) · 1.42 KB
/
dirs-vs-index
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
#!/usr/bin/env bash
#
# dirs-vs-index v1.0
#
# Compare folders listed in the root directory to those outlined in `index.md`
# This shows data set maintainers which folders aren't being indexed properly
#
# 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 WRDLS_PAGER
[ -f scripts/shared/colors ] && source -- scripts/shared/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
echo -en "${bluef}${avar}${reset} "
echo -e $(grep --color=ALWAYS -Hirna -- "${avar}" INDEX.md | awk 'BEGIN { FS=":"; } END { print($1); }')
done <&2- | $PAGER
exit 0