forked from STLVNUB/CloverGrower
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCloverGrower.lib
executable file
·53 lines (46 loc) · 1.29 KB
/
CloverGrower.lib
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
#! /bin/bash
# Usefull functions for CloverGrower
function echob() {
echo $(tput bold)"$1"$(tput sgr0)
}
# Convert argument to lowercase
function lc() {
echo "$1" | tr '[A-Z]' '[a-z]'
}
function get_hours() {
starth=$(date "+%H")
# message Afternoon is longest len so others must have same len also
# this is for echob use of $hours i.e in
# echob "* Good $hours *"
if [ $starth -ge 04 ] && [ $starth -le 12 ]; then # errors with [[ why??
hours="Morning. "
elif [ $starth -ge 12 ] && [ $starth -le 17 ]; then
hours="Afternoon."
elif [ $starth -ge 18 ] && [ $starth -le 21 ]; then
hours="Evening. "
else
hours="Night. "
fi
printf "%-10s" $hours
}
# Simple check return value function
function checkit(){
return_val=$?
local msg="$1"
local error_msg="${2:-}"
if [[ "${return_val}" -eq 0 ]]; then
echob "CloverGrower V$myVersion $msg OK"
return $return_val
else
echob "CloverGrower V$myVersion $msg $error_msg ERROR!!"
echob "Good $hours"
exit $return_val
fi
}
# Function that return svn revision
function getSvnRevision() {
# Arguments:
# $1: location of an svn repository (directory or URL)
[[ $# -ne 1 ]] && echo "getSvnRevision: invalid number of arguments" >&2 && exit 1
svn info "$1" | sed -n 's/^Revision: *//p'
}