git.stg.codes
/
stg.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
Moved plugin-related things into a separate file.
[stg.git]
/
functest
/
functions
1
trim()
2
{
3
printf "$1" | sed -e 's/^ *//' -e 's/ *$//'
4
}
5
6
getField()
7
{
8
NAME="$1"
9
DATA="$2"
10
11
printf "$DATA" | grep "$NAME" > /dev/null 2> /dev/null
12
if [ "$?" != "0" ]
13
then
14
return 1
15
fi
16
17
trim `printf "$DATA" | cut -d: -f2`
18
}
19
20
getFields()
21
{
22
NAME=$1
23
DATA=$2
24
25
IFS=`printf '\n+'`
26
for LINE in $DATA
27
do
28
VALUE=`getField $NAME $LINE` && printf "%s\n" "$VALUE"
29
done
30
}
31
32
count()
33
{
34
if [ "$1" == "" ]
35
then
36
printf "0\n"
37
else
38
printf "$1\n" | wc -l
39
fi
40
}