-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodo.bash
executable file
·36 lines (33 loc) · 891 Bytes
/
todo.bash
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
#!/bin/bash
#
# todo.bash - Find all TODO comments in specified files tracked by git
#
ltd()
{
for FILE in $(git ls-files)
do
if [ ${FILE: -$LEN} == $LFE ] # Check for source files
then
grep TODO $FILE >/dev/null
if [ $? -eq 0 ] # Check if file contains string
then
echo \## $FILE
# Print lines containing string
# and replace preceding text with nothing
# TODO(PM) Markdown newline requires two spaces at the EOL
grep "#\s*TODO" $FILE | sed 's/^.*TODO//g'
echo # Print new line
fi
fi
done
}
# Main control flow
if [ -z "$1" ]
then
echo WARNING: Please specify a file extension
exit 84
else
LFE=$1 # Programming language file extension
LEN=${#LFE} # File extension length
ltd
fi