-
-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathgrabenv.sh
More file actions
52 lines (47 loc) · 1.2 KB
/
grabenv.sh
File metadata and controls
52 lines (47 loc) · 1.2 KB
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
#!/bin/bash
#
# This script has been created as part of the Blueprint source code
# and uses the same license as the rest of the codebase.
#
# Commands:
# - grabAppUrl string
# - grabAppDebug bool
# - grabAppTimezone string
# - grabAppLocale string
source "${BLUEPRINT__FOLDER}"/.env 2>> "${BLUEPRINT__DEBUG}"
slowEnv() {
cd "${BLUEPRINT__FOLDER}" || exit
env_file=".env"
while IFS= read -r line; do
if [[ $line == \#* ]]; then
continue
fi
if [[ $line == *"="* ]]; then
variable_name=$(echo "$line" | cut -d= -f1)
variable_value=$(echo "$line" | cut -d= -f2-)
variable_name=$(echo "$variable_name" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
variable_value=$(echo "$variable_value" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | sed 's/^"\(.*\)"$/\1/')
declare "$variable_name=$variable_value"
fi
done < "$env_file"
}
if [[
( "$APP_URL" == "" ) ||
( "$APP_DEBUG" == "" ) ||
( "$APP_TIMEZONE" == "" ) ||
( "$APP_LOCALE" == "" )
]]; then
slowEnv
fi
grabAppUrl() {
echo "$APP_URL";
}
grabAppDebug() {
echo "$APP_DEBUG";
}
grabAppTimezone() {
echo "$APP_TIMEZONE";
}
grabAppLocale() {
echo "$APP_LOCALE";
}