-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbash_common.sh
99 lines (78 loc) · 1.15 KB
/
bash_common.sh
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#! /bin/echo Please-source
set -o nounset
set -o errexit
set -o posix
set -o pipefail
export LC_ALL=C
export NOCOLOR='\033[0m'
export RED='\033[1;31m'
export GREEN='\033[1;32m'
export YELLOW='\033[1;33m'
export BLUE='\033[1;34m'
export MAGENTA='\033[35m'
function error
{
local MSG="$1"
echo ""
echo -e "${RED}ERROR${NOCOLOR}\07"
echo -e "$MSG"
exit 1
}
function section
{
local MSG="$1"
echo ""
echo -e "${GREEN}${MSG}${NOCOLOR}"
}
function super_section
{
local MSG="$1"
local S="*** $MSG ***"
local T=${S//?/*}
echo ""
section "$T\n$S\n$T"
date
}
function warning
{
local MSG="$1"
echo -e "${YELLOW}${MSG}${NOCOLOR}"
}
function success
{
echo ""
echo ""
echo -e "${BLUE}SUCCESS${NOCOLOR}"
if [ $SHLVL -le 2 ]; then
printf "\07\07"
sleep 1
printf "\07\07"
sleep 1
printf "\07\07"
fi
date
#exit 0
}
function comment
{
local MSG="$1"
echo -e "${MAGENTA}${MSG}${NOCOLOR}" >> /dev/stderr
}
function file2var
{
local F=$1
local DEFAULT="$2"
if [ -e $F ]; then
cat $F
else
echo $DEFAULT
fi
}
function differ
{
local F1=$1
local F2=$2
set -x
diff $F1 $F2
set +x
}