-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdescribeFunction.sh
More file actions
executable file
·62 lines (55 loc) · 1.14 KB
/
describeFunction.sh
File metadata and controls
executable file
·62 lines (55 loc) · 1.14 KB
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
#!/bin/bash
#
# Michael Piko
# Description:
# Date created: dd-mm-20yy
# last modified: dd-mm-20yy
#see setEnvironment.sh, functions.sh, and variables.sh for explaination
. setEnvironment.sh
if ! enoughArgs 1 $#
then
echo Need to supply a function to look up
echo Usage: describeFunction.sh functionname
exit
fi
FINDFUNC=$1
OLDIFS=$IFS
IFS="
"
for LINE in $(grep '() ' $HOME/bin/functs/func*.sh | cut -f1 -d\( | grep "$FINDFUNC")
do
TMPFUNCTION=$(echo $LINE | cut -f2 -d:)
if [ $FINDFUNC = $TMPFUNCTION ]
then
FOUND="TRUE"
FUNCTION=$TMPFUNCTION
FILEPATH=$(echo $LINE | cut -f1 -d:)
FILE=$(basename $FILEPATH)
echo FUNCTON NAME: $FUNCTION
echo LOCATION: $FILE
fi
done
if [ -z $FOUND ]
then
echo "Could not find function: $FINDFUNC"
exit
fi
FOUND="FALSE"
for LINE in $(cat $HOME/bin/functs/$FILE)
do
if [ $FOUND = "TRUE" ]
then
CHAR=$(echo $LINE | cut -c1)
if [ $CHAR = '#' ]
then
echo $LINE | sed 's/^#/ /'
else
break
fi
fi
TMP=$(echo $LINE | grep "^$FUNCTION(")
if [ ! -z $TMP ]
then
FOUND="TRUE"
fi
done