mirror of
https://github.com/uprightbass360/AzerothCore-RealmMaster.git
synced 2026-01-13 00:58:34 +00:00
Allow blank defaults in get_template_value
This commit is contained in:
15
setup.sh
15
setup.sh
@@ -26,18 +26,19 @@ get_template_value() {
|
||||
|
||||
# Extract value, handling variable expansion syntax like ${VAR:-default}
|
||||
local value
|
||||
value=$(grep "^${key}=" "$template_file" | head -1 | cut -d'=' -f2- | sed 's/^"\(.*\)"$/\1/')
|
||||
local raw_line
|
||||
raw_line=$(grep "^${key}=" "$template_file" | head -1)
|
||||
if [ -z "$raw_line" ]; then
|
||||
echo "ERROR: Required key '$key' not found in .env.template" >&2
|
||||
exit 1
|
||||
fi
|
||||
value="${raw_line#*=}"
|
||||
value=$(echo "$value" | sed 's/^"\(.*\)"$/\1/')
|
||||
|
||||
# Handle ${VAR:-default} syntax by extracting the default value
|
||||
if [[ "$value" =~ ^\$\{[^}]*:-([^}]*)\}$ ]]; then
|
||||
value="${BASH_REMATCH[1]}"
|
||||
fi
|
||||
|
||||
if [ -z "$value" ]; then
|
||||
echo "ERROR: Required key '$key' not found in .env.template" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$value"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user