mirror of https://github.com/WerWolv/ImHex.git
patterns: Make std::env return an empty string and throw a warning if env var doesn't exist
This commit is contained in:
parent
ea92e17ca0
commit
0efb226c2f
|
@ -86,7 +86,13 @@ namespace hex::plugin::builtin {
|
||||||
ContentRegistry::PatternLanguageFunctions::add(nsStd, "env", 1, [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
ContentRegistry::PatternLanguageFunctions::add(nsStd, "env", 1, [](Evaluator *ctx, auto params) -> std::optional<Token::Literal> {
|
||||||
auto name = Token::literalToString(params[0], false);
|
auto name = Token::literalToString(params[0], false);
|
||||||
|
|
||||||
return ctx->getEnvVariable(name);
|
auto env = ctx->getEnvVariable(name);
|
||||||
|
if (env)
|
||||||
|
return env;
|
||||||
|
else {
|
||||||
|
ctx->getConsole().log(LogConsole::Level::Warning, hex::format("environment variable '{}' does not exist", name));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue