summaryrefslogtreecommitdiffstats
path: root/ci/common/tools.sh
blob: 45db67e1a72ff5340753e070366fbd5554e930db (plain)
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
##############################################################################
# Copyright (c) 2017 Nokia and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

# include only once
[ ! -z "$_tools_included" ] && return || readonly _tools_included=true

#######################################
# Echo printing in yellow bold color
# Arguments:
#   Same as for echo
# Returns:
#   None
#######################################
function echo_info { (
    # don't clutter the script output with the xtrace of the echo command
    { set +x; } 2> /dev/null

    yellow_bold='\033[1;33m'
    color_off='\033[0m'
    echo "${@:1:($#-1)}" -e "$yellow_bold${@: -1}$color_off";
  )
}

#######################################
# Echo error (to stderr)
# Arguments:
#   Same as for echo
# Returns:
#   None
#######################################
function echo_error { (
    # don't clutter the script output with the xtrace of the echo command
    { set +x; } 2> /dev/null

    red_bold='\033[1;31m'
    color_off='\033[0m'
    >&2 echo "${@:1:($#-1)}" -e "$red_bold${@: -1}$color_off";
  )
}

#######################################
# Echo warning (to stderr)
# Arguments:
#   Same as for echo
# Returns:
#   None
#######################################
function echo_warning { (
    # don't clutter the script output with the xtrace of the echo command
    { set +x; } 2> /dev/null

    red_italic='\033[3;91m'
    color_off='\033[0m'
    >&2 echo "${@:1:($#-1)}" -e "$red_italic${@: -1}$color_off";
  )
}