From a8db4f0b0e203f464aa73928b491bc88506f47a4 Mon Sep 17 00:00:00 2001 From: WindSoilder Date: Mon, 23 May 2022 20:47:08 +0800 Subject: [PATCH] load config when requried (#5618) --- src/main.rs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/main.rs b/src/main.rs index 856e5d5e7a..3db83f5d49 100644 --- a/src/main.rs +++ b/src/main.rs @@ -195,6 +195,25 @@ fn main() -> Result<()> { NUSHELL_FOLDER, 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( commands, @@ -217,6 +236,25 @@ fn main() -> Result<()> { NUSHELL_FOLDER, 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( script_name,