;;
*)
log DEBUG "Invalid line in configuration file: ${line}"
- continue
+ ;;
+ esac
+ done < ${file}
+}
+
+function config_read_array() {
+ local file=${1}
+ assert isset file
+ shift
+
+ local array=${1}
+ assert isset array
+ shift
+
+ local valid_keys=$@
+
+ # Exit if the file cannot be read.
+ [ -r "${file}" ] || return ${EXIT_ERROR}
+
+ local line key val
+ while read -r line; do
+ case "${line}" in
+ *=*)
+ key=$(cli_get_key ${line})
+
+ # If valid_keys is set, key must be in the list.
+ if [ -n "${valid_keys}" ]; then
+ if ! listmatch ${key} ${valid_keys}; then
+ log DEBUG "Ignoring configuration setting: ${key}"
+ continue
+ fi
+ fi
+
+ val=$(cli_get_val ${line})
+ val=$(config_strip ${val})
+
+ # Assign variable.
+ printf -v "${array}["${key}"]" "%s" "${val}"
+ ;;
+ *)
+ log DEBUG "Invalid line in configuration file: ${line}"
;;
esac
done < ${file}