forked from extern/nushell
Get $nu.config-path
and $nu.env-path
from EngineState
(#6366)
* Get `$nu.config-path` and `$nu.env-path` from `EngineState` Signed-off-by: nibon7 <nibon7@163.com> * replace tuple with hashmap Signed-off-by: nibon7 <nibon7@163.com> * refactor set_config_path Signed-off-by: nibon7 <nibon7@163.com> Signed-off-by: nibon7 <nibon7@163.com>
This commit is contained in:
@ -1298,6 +1298,22 @@ pub fn eval_variable(
|
||||
let mut output_cols = vec![];
|
||||
let mut output_vals = vec![];
|
||||
|
||||
if let Some(path) = engine_state.get_config_path("config-path") {
|
||||
output_cols.push("config-path".into());
|
||||
output_vals.push(Value::String {
|
||||
val: path.to_string_lossy().to_string(),
|
||||
span,
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(path) = engine_state.get_config_path("env-path") {
|
||||
output_cols.push("env-path".into());
|
||||
output_vals.push(Value::String {
|
||||
val: path.to_string_lossy().to_string(),
|
||||
span,
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(mut config_path) = nu_path::config_dir() {
|
||||
config_path.push("nushell");
|
||||
let mut env_config_path = config_path.clone();
|
||||
@ -1321,21 +1337,25 @@ pub fn eval_variable(
|
||||
span,
|
||||
});
|
||||
|
||||
config_path.push("config.nu");
|
||||
if engine_state.get_config_path("config-path").is_none() {
|
||||
config_path.push("config.nu");
|
||||
|
||||
output_cols.push("config-path".into());
|
||||
output_vals.push(Value::String {
|
||||
val: config_path.to_string_lossy().to_string(),
|
||||
span,
|
||||
});
|
||||
output_cols.push("config-path".into());
|
||||
output_vals.push(Value::String {
|
||||
val: config_path.to_string_lossy().to_string(),
|
||||
span,
|
||||
});
|
||||
}
|
||||
|
||||
env_config_path.push("env.nu");
|
||||
if engine_state.get_config_path("env-path").is_none() {
|
||||
env_config_path.push("env.nu");
|
||||
|
||||
output_cols.push("env-path".into());
|
||||
output_vals.push(Value::String {
|
||||
val: env_config_path.to_string_lossy().to_string(),
|
||||
span,
|
||||
});
|
||||
output_cols.push("env-path".into());
|
||||
output_vals.push(Value::String {
|
||||
val: env_config_path.to_string_lossy().to_string(),
|
||||
span,
|
||||
});
|
||||
}
|
||||
|
||||
loginshell_path.push("login.nu");
|
||||
|
||||
|
Reference in New Issue
Block a user