-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzlang-linker
46 lines (38 loc) · 1.04 KB
/
zlang-linker
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
#!/bin/zsh
# Check ZSH version
if [[ -z "$ZSH_VERSION" ]] && [[ -z "$ZLANG_SUPPRESS_WARNING" ]]; then
echo "Warning: ZLang is intended to run in zsh environment."
fi
# Will return to parent working directory
export ORIGH="$(pwd)"
# Set the root directory for eBash
if [[ -z "$ZLANG_HOME" ]]; then
export ZLANG_HOME="$(dirname "$(readlink -f "$0")")"
elif [[ ! -z "$1" ]]; then
export ZLANG_HOME="$1"
fi
# Load all zlangbase using for loop
cd "${ZLANG_HOME}/base" 2>/dev/null
if [[ "$?" != "0" ]]; then
echo "Error: Unable to locate and enter ZLANG_HOME."
exit 9
fi
while read DATAFILE
do
# Load
source "${DATAFILE}" 2>/dev/null
if [[ "$?" != "0" ]]; then
echo "Error: Failed loading base component."
exit 9
fi
done <<< "$(ls -1 | grep ".zlangbase")"
# Return to parent working directory and remove the memory
cd "$ORIGH" 2>/dev/null
if [[ "$?" != "0" ]]; then
echo "Error: Failed to enter original working directory."
exit 9
fi
unset ORIGH 2>/dev/null
if [[ "$ZLANG_PREP_PRINT" == "1" ]]; then
echo "ZLang environment preparation successful."
fi