mirror of
https://github.com/nushell/nushell.git
synced 2024-12-23 15:39:06 +01:00
Add a sync from the known path to the env (#3335)
This commit is contained in:
parent
3b2ed7631f
commit
da81e21bf2
@ -25,6 +25,7 @@ pub(crate) fn run_external_command(
|
|||||||
) -> Result<InputStream, ShellError> {
|
) -> Result<InputStream, ShellError> {
|
||||||
trace!(target: "nu::run::external", "-> {}", command.name);
|
trace!(target: "nu::run::external", "-> {}", command.name);
|
||||||
|
|
||||||
|
context.sync_path_to_env();
|
||||||
if !context.host.lock().is_external_cmd(&command.name) {
|
if !context.host.lock().is_external_cmd(&command.name) {
|
||||||
return Err(ShellError::labeled_error(
|
return Err(ShellError::labeled_error(
|
||||||
"Command not found",
|
"Command not found",
|
||||||
|
@ -138,6 +138,7 @@ fn maybe_autocd_dir(cmd: &ExternalCommand, ctx: &mut EvaluationContext) -> Optio
|
|||||||
// - the command name ends in a path separator, or
|
// - the command name ends in a path separator, or
|
||||||
// - it's not a command on the path and no arguments were given.
|
// - it's not a command on the path and no arguments were given.
|
||||||
let name = &cmd.name;
|
let name = &cmd.name;
|
||||||
|
ctx.sync_path_to_env();
|
||||||
let path_name = if name.ends_with(std::path::is_separator)
|
let path_name = if name.ends_with(std::path::is_separator)
|
||||||
|| (cmd.args.is_empty()
|
|| (cmd.args.is_empty()
|
||||||
&& PathBuf::from(name).is_dir()
|
&& PathBuf::from(name).is_dir()
|
||||||
|
@ -98,6 +98,17 @@ impl EvaluationContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn sync_path_to_env(&self) {
|
||||||
|
let env_vars = self.scope.get_env_vars();
|
||||||
|
|
||||||
|
for (var, val) in env_vars {
|
||||||
|
if var == "PATH" || var == "Path" || var == "path" {
|
||||||
|
std::env::set_var(var, val);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub(crate) fn get_command(&self, name: &str) -> Option<Command> {
|
pub(crate) fn get_command(&self, name: &str) -> Option<Command> {
|
||||||
self.scope.get_command(name)
|
self.scope.get_command(name)
|
||||||
|
@ -101,6 +101,7 @@ pub fn process_script(
|
|||||||
})
|
})
|
||||||
.unwrap_or("");
|
.unwrap_or("");
|
||||||
|
|
||||||
|
ctx.sync_path_to_env();
|
||||||
if internal_name == "run_external"
|
if internal_name == "run_external"
|
||||||
&& args
|
&& args
|
||||||
.positional
|
.positional
|
||||||
|
Loading…
Reference in New Issue
Block a user