forked from trimstray/sandmap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimport
48 lines (33 loc) · 1.51 KB
/
import
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
#!/usr/bin/env bash
# shellcheck shell=bash
################################################################################
#################### External variables/functions and libs #####################
################################################################################
# Set of external files with variables, functions and other. The configuration
# of each of them is in lib directory. The fd_stack array stores the names of
# attached files. If you create a new file with some interesting function,
# name it appropriately and insert to the array.
# Example:
# - lib/kill_process - file with your function
# - _fd_stack=("kill_process") - says to include this file in the script
readonly _fd_stack=(init_config init_session load_modules init_cli \
cli_distributor cli_help cli_show init_module \
module_help module_show module_info show_config \
set_config init_search)
if [[ "${#_fd_stack[@]}" -ne 0 ]] ; then
for _fd in "${_fd_stack[@]}" ; do
# shellcheck disable=SC2154
_fd_full_path="${_lib}/${_fd}"
if [[ ! -z "$_fd_full_path" ]] && [[ -e "$_fd_full_path" ]] ; then
# If the file exists is loaded.
# shellcheck disable=SC1090
source "$_fd_full_path"
elif [[ -z "$_fd_full_path" ]] ; then
printf "incorrectly loaded '%s' file (incorrect filename)" "$_fd_full_path"
_exit_ "1"
else
printf "incorrectly loaded '%s' file (does not exist?)" "$_fd_full_path"
_exit_ "1"
fi
done
fi