-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathheader
58 lines (52 loc) · 1.9 KB
/
header
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
#-----------------------------------------------------------------------
#
# Basescript function
#
# The basescript functions were designed to work as abstract function,
# so it could be used in many different contexts executing specific job
# always remembering Unix concept DOTADIW - "Do One Thing And Do It Well"
#
# Developed by
# Evert Ramos <evert.ramos@gmail.com>
#
# Copyright Evert Ramos
#
#-----------------------------------------------------------------------
#
# Be careful when editing this file, it is part of a bigger script!
#
# Basescript - https://github.com/evertramos/basescript
#
#-----------------------------------------------------------------------
#-----------------------------------------------------------------------
# This function has one main objective:
# 1.
#
# You must/might inform the parameters below:
# 1.
# 2. [optional] (default: )
# 99. [optional] (default: true) Stop execution on error
#
#-----------------------------------------------------------------------
function_name()
{
local LOCAL_ LOCAL_STOP_EXECUTION_ON_ERROR
LOCAL_=${1:-null}
LOCAL_STOP_EXECUTION_ON_ERROR=${99:-true}
if [[ $LOCAL_ == "" || $LOCAL_ == null ]]; then
if [[ ! $(declare -F echoerror) == "" ]]; then
echoerror "You must inform the required argument(s) to the function: '${FUNCNAME[0]}'" ${LOCAL_STOP_EXECUTION_ON_ERROR}
else
echo "You must inform the required argument(s) to the function: '${FUNCNAME[0]}'"
[[ "$LOCAL_STOP_EXECUTION_ON_ERROR" == true ]] && exit 1
fi
fi
if [[ "$DEBUG" == true ]]; then
if [[ ! $(declare -F echowarning) == "" ]]; then
echowarning "You are running..... xyz - [function: ${FUNCNAME[0]}]"
else
echo "You are running..... xyz - [function: ${FUNCNAME[0]}]"
[[ "$LOCAL_STOP_EXECUTION_ON_ERROR" == true ]] && exit 1
fi
fi
}