load config when requried (#5618)

This commit is contained in:
WindSoilder 2022-05-23 20:47:08 +08:00 committed by GitHub
parent 98a4280c41
commit a8db4f0b0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -195,6 +195,25 @@ fn main() -> Result<()> {
NUSHELL_FOLDER, NUSHELL_FOLDER,
is_perf_true(), is_perf_true(),
); );
// only want to load config and env if relative argument is provided.
if binary_args.config_file.is_some() {
config_files::read_config_file(
&mut engine_state,
&mut stack,
binary_args.config_file,
is_perf_true(),
false,
);
}
if binary_args.env_file.is_some() {
config_files::read_config_file(
&mut engine_state,
&mut stack,
binary_args.env_file,
is_perf_true(),
true,
);
}
let ret_val = evaluate_commands( let ret_val = evaluate_commands(
commands, commands,
@ -217,6 +236,25 @@ fn main() -> Result<()> {
NUSHELL_FOLDER, NUSHELL_FOLDER,
is_perf_true(), is_perf_true(),
); );
// only want to load config and env if relative argument is provided.
if binary_args.config_file.is_some() {
config_files::read_config_file(
&mut engine_state,
&mut stack,
binary_args.config_file,
is_perf_true(),
false,
);
}
if binary_args.env_file.is_some() {
config_files::read_config_file(
&mut engine_state,
&mut stack,
binary_args.env_file,
is_perf_true(),
true,
);
}
let ret_val = evaluate_file( let ret_val = evaluate_file(
script_name, script_name,