mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 00:48:59 +02:00
Make get_env_var
return a reference to a Value
(#13987)
# Description Title says it all, changes `EngineState::get_env_var` to return a `Option<&'a Value>` instead of an owned `Option<Value>`. This avoids some unnecessary clones. I also made a similar change to the `PluginExecutionContext` trait.
This commit is contained in:
@ -107,7 +107,7 @@ impl Command for Cd {
|
||||
// Set OLDPWD.
|
||||
// We're using `Stack::get_env_var()` instead of `EngineState::cwd()` to avoid a conversion roundtrip.
|
||||
if let Some(oldpwd) = stack.get_env_var(engine_state, "PWD") {
|
||||
stack.add_env_var("OLDPWD".into(), oldpwd)
|
||||
stack.add_env_var("OLDPWD".into(), oldpwd.clone())
|
||||
}
|
||||
|
||||
match have_permission(&path) {
|
||||
|
@ -314,7 +314,7 @@ fn send_form_request(
|
||||
Value::List { ref vals, .. } => {
|
||||
if vals.len() % 2 != 0 {
|
||||
return Err(ShellErrorOrRequestError::ShellError(ShellError::IncorrectValue {
|
||||
msg: "Body type 'list' for form requests requires paired values. E.g.: [foo, 10]".into(),
|
||||
msg: "Body type 'list' for form requests requires paired values. E.g.: [foo, 10]".into(),
|
||||
val_span: body.span(),
|
||||
call_span: span,
|
||||
}));
|
||||
@ -901,6 +901,7 @@ fn retrieve_http_proxy_from_env(engine_state: &EngineState, stack: &mut Stack) -
|
||||
.or(stack.get_env_var(engine_state, "https_proxy"))
|
||||
.or(stack.get_env_var(engine_state, "HTTPS_PROXY"))
|
||||
.or(stack.get_env_var(engine_state, "ALL_PROXY"))
|
||||
.cloned()
|
||||
.and_then(|proxy| proxy.coerce_into_string().ok())
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ prints out the list properly."#
|
||||
let icons_param: bool = call.has_flag(engine_state, stack, "icons")?;
|
||||
let config = &stack.get_config(engine_state);
|
||||
let env_str = match stack.get_env_var(engine_state, "LS_COLORS") {
|
||||
Some(v) => Some(env_to_string("LS_COLORS", &v, engine_state, stack)?),
|
||||
Some(v) => Some(env_to_string("LS_COLORS", v, engine_state, stack)?),
|
||||
None => None,
|
||||
};
|
||||
|
||||
|
@ -623,7 +623,7 @@ fn handle_row_stream(
|
||||
let ls_colors_env_str = match input.stack.get_env_var(input.engine_state, "LS_COLORS") {
|
||||
Some(v) => Some(env_to_string(
|
||||
"LS_COLORS",
|
||||
&v,
|
||||
v,
|
||||
input.engine_state,
|
||||
input.stack,
|
||||
)?),
|
||||
|
Reference in New Issue
Block a user