-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshellib.sh
50 lines (39 loc) · 1.18 KB
/
shellib.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
# shellcheck shell=bash
# Make sure the lib is sourced as Bash
if [ -z "$BASH" ]; then
echo "$0 ✗ Must be sourced as Bash" >&2
return 1
fi
# Prevent multi-sourcing
shellib_sourced=${shellib_sourced:-0}
# Incrementing by +=, because ++ causes failed tests
((shellib_sourced += 1))
if [ "$shellib_sourced" -ne '1' ]; then
echo "${TEST_ARGV:-$0} 🛈 Shouldn't be sourced multiple times" >&2
return 1
fi
# Environmental variables
# $TEST_ARGV ... indexed array with mock arguments for $0, $1, and so on
# $TEST_EUID ... integer with mock EUID
# Constants
# shellcheck disable=SC2034
{
# Bumped up automatically by calling scripts/set-ver
readonly shellib_version="0.11.6"
} 2>/dev/null
# Functions
# Output "Shellib version" to stdout
# Stdout: Shellib version
function get_version() {
echo "$shellib_version"
}
# Shellib modules
shellib_path="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
# shellcheck source=src/process.sh
. "$shellib_path/src/process.sh"
# shellcheck source=src/system.sh
. "$shellib_path/src/system.sh"
# shellcheck source=src/events.sh
. "$shellib_path/src/events.sh"
# shellcheck source=src/packages.sh
. "$shellib_path/src/packages.sh"