1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-11-06 08:49:29 +02:00

Use standard environment variable format in hrnCfgEnv*().

The option portion was not being capitalized or replacing - with _.

The parser does not care, but in cases where we have mixed hrnCfgEnv*()/setenv() calls the env variable might not get cleared, which can lead to funny test results.
This commit is contained in:
David Steele
2021-01-21 11:59:19 -05:00
parent 4e56948128
commit d3d484b27c

View File

@@ -182,6 +182,13 @@ hrnCfgArgKeyRawReset(StringList *argList, ConfigOption optionId, unsigned option
}
/**********************************************************************************************************************************/
__attribute__((always_inline)) static inline const char *
hrnCfgEnvName(ConfigOption optionId, unsigned optionKey)
{
return strZ(
strReplaceChr(strUpper(strNewFmt(HRN_PGBACKREST_ENV "%s", cfgParseOptionKeyIdxName(optionId, optionKey - 1))), '-', '_'));
}
void
hrnCfgEnvRaw(ConfigOption optionId, const String *value)
{
@@ -203,7 +210,7 @@ hrnCfgEnvRawZ(ConfigOption optionId, const char *value)
void
hrnCfgEnvKeyRawZ(ConfigOption optionId, unsigned optionKey, const char *value)
{
setenv(strZ(strNewFmt(HRN_PGBACKREST_ENV "%s", cfgParseOptionKeyIdxName(optionId, optionKey - 1))), value, true);
setenv(hrnCfgEnvName(optionId, optionKey), value, true);
}
void
@@ -215,5 +222,5 @@ hrnCfgEnvRemoveRaw(ConfigOption optionId)
void
hrnCfgEnvKeyRemoveRaw(ConfigOption optionId, unsigned optionKey)
{
unsetenv(strZ(strNewFmt(HRN_PGBACKREST_ENV "%s", cfgParseOptionKeyIdxName(optionId, optionKey - 1))));
unsetenv(hrnCfgEnvName(optionId, optionKey));
}