diff --git a/settings.json.docker b/settings.json.docker index 0d089177..99b83bff 100644 --- a/settings.json.docker +++ b/settings.json.docker @@ -65,6 +65,9 @@ * "password": "${PASSW}" // if PASSW is not defined would result in password === null * "password": "${PASSW:}" // if PASSW is not defined would result in password === '' * + * If you want to use an empty value (null) as default value for a variable, + * simply do not set it, without putting any colons: "${ABIWORD}". + * * 3) if you want to use newlines in the default value of a string parameter, * use "\n" as usual. * diff --git a/settings.json.template b/settings.json.template index 92928289..f01dc780 100644 --- a/settings.json.template +++ b/settings.json.template @@ -56,6 +56,9 @@ * "password": "${PASSW}" // if PASSW is not defined would result in password === null * "password": "${PASSW:}" // if PASSW is not defined would result in password === '' * + * If you want to use an empty value (null) as default value for a variable, + * simply do not set it, without putting any colons: "${ABIWORD}". + * * 3) if you want to use newlines in the default value of a string parameter, * use "\n" as usual. * diff --git a/src/node/utils/Settings.js b/src/node/utils/Settings.js index 8e478f0d..369a4485 100644 --- a/src/node/utils/Settings.js +++ b/src/node/utils/Settings.js @@ -421,6 +421,14 @@ function storeSettings(settingsObj) { /* * If stringValue is a numeric string, or its value is "true" or "false", coerce * them to appropriate JS types. Otherwise return stringValue as-is. + * + * Please note that this function is used for converting types for default + * values in the settings file (for example: "${PORT:9001}"), and that there is + * no coercition for "null" values. + * + * If the user wants a variable to be null by default, he'll have to use the + * short syntax "${ABIWORD}", and not "${ABIWORD:null}": the latter would result + * in the literal string "null", instead. */ function coerceValue(stringValue) { // cooked from https://stackoverflow.com/questions/175739/built-in-way-in-javascript-to-check-if-a-string-is-a-valid-number @@ -525,7 +533,7 @@ function lookupEnvironmentVariables(obj) { const defaultValue = match[3]; if ((envVarValue === undefined) && (defaultValue === undefined)) { - console.warn(`Environment variable "${envVarName}" does not contain any value for configuration key "${key}", and no default was given. Returning null. Please check your configuration and environment settings.`); + console.warn(`Environment variable "${envVarName}" does not contain any value for configuration key "${key}", and no default was given. Returning null.`); /* * We have to return null, because if we just returned undefined, the