-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.pyamsoft
61 lines (52 loc) · 1.36 KB
/
.pyamsoft
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
# shellcheck shell=sh
# We allow scripts to call this file again and again
# But since pieces of the configuration are controlled by their own variables
# We are correctly guarded from double executes
#
# If we have already been sourced, exit out
# if [ -n "${PYAMSOFT_ENVIRONMENT}" ]; then
# return 0
# fi
_cfg="${XDG_CONFIG_HOME:-${HOME}/.config}"
env_os="$(uname)"
# Create the environment flag
if [ -z "${PYAMSOFT_ENVIRONMENT}" ]; then
PYAMSOFT_ENVIRONMENT=""
fi
for _env_conf in "${_cfg}"/pyamsoft.d/*.conf; do
# Sometimes os can get unset. Reset it here
if [ -z "${env_os}" ]; then
env_os="$(uname)"
fi
# shellcheck disable=SC1090
[ -r "${_env_conf}" ] && {
case "${_env_conf}" in
*.linux)
if [ "${env_os}" = "Linux" ]; then
. "${_env_conf}" || {
printf -- 'Linux ENV setup script failed: %s\n' "${_env_conf}"
}
fi
;;
*.macos)
if [ "${env_os}" = "Darwin" ]; then
. "${_env_conf}" || {
printf -- 'MacOS ENV setup script failed: %s\n' "${_env_conf}"
}
fi
;;
*)
. "${_env_conf}" || {
printf -- 'ENV setup script failed: %s\n' "${_env_conf}"
}
;;
esac
}
unset _env_conf
done
unset _env_conf
unset env_os
unset _cfg
# Mark environment as set up
export PYAMSOFT_ENVIRONMENT
return 0