fix: remove underscores from cfg options in assoc array

Remove any possible underscores from the config options when creating
keys for the associative array used to look them up after capturing
environment variables.

This is a possible regression from fc0363a.
pull/6/head
d3adb5 2022-05-15 10:43:12 -03:00
rodzic fc0363a448
commit 3f908fd921
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 36962FB62A3776A5
1 zmienionych plików z 5 dodań i 3 usunięć

Wyświetl plik

@ -10,10 +10,12 @@ readonly CONFIG_REGEX="^(\;|\#)?\ *([a-zA-Z_0-9]+)=.*"
readarray -t existing_config_options < <(sed -En "s/$CONFIG_REGEX/\2/p" "$BARE_BONES_CONFIG_FILE")
# Create an associative array for faster config option lookup
declare -A config_from_uppercase
declare -A option_for
for config in "${existing_config_options[@]}"; do
config_from_uppercase["${config^^}"]="$config"
# Ignore underscores during lookup
no_underscores="${config//_/}"
option_for["${no_underscores^^}"]="$config"
done
# Grab the original command line that is supposed to start the Mumble server
@ -63,7 +65,7 @@ else
while IFS='=' read -d '' -r var value; do
# Uppercase and remove underscores so MUMBLE_CONFIG_A_B == MUMBLE_CONFIG_AB
uppercase_variable="${var/MUMBLE_CONFIG_/}"
config_option="${config_from_uppercase[${uppercase_variable//_/}]}"
config_option="${option_for[${uppercase_variable//_/}]}"
if [[ -z "$config_option" ]]; then
>&2 echo "[ERROR]: Unable to find config corresponding to variable \"$var\""