mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 00:13:21 +01:00
Fix tests and run_external
message bug
This commit is contained in:
parent
cba76b6e23
commit
c11a17e6c5
@ -45,6 +45,7 @@ On Windows based systems, Nushell will wait for the command to finish and then e
|
|||||||
call.head,
|
call.head,
|
||||||
engine_state,
|
engine_state,
|
||||||
stack,
|
stack,
|
||||||
|
&cwd,
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
executable
|
executable
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use nu_cmd_base::hook::eval_hook;
|
use nu_cmd_base::hook::eval_hook;
|
||||||
use nu_engine::{command_prelude::*, env_to_strings, get_eval_expression};
|
use nu_engine::{command_prelude::*, env_to_strings, get_eval_expression};
|
||||||
use nu_path::{dots::expand_ndots, expand_tilde};
|
use nu_path::{dots::expand_ndots, expand_tilde, AbsolutePath};
|
||||||
use nu_protocol::{did_you_mean, process::ChildProcess, ByteStream, NuGlob, OutDest, Signals};
|
use nu_protocol::{did_you_mean, process::ChildProcess, ByteStream, NuGlob, OutDest, Signals};
|
||||||
use nu_system::ForegroundChild;
|
use nu_system::ForegroundChild;
|
||||||
use nu_utils::IgnoreCaseExt;
|
use nu_utils::IgnoreCaseExt;
|
||||||
@ -78,7 +78,13 @@ impl Command for External {
|
|||||||
// effect if it's an absolute path already
|
// effect if it's an absolute path already
|
||||||
let paths = nu_engine::env::path_str(engine_state, stack, call.head)?;
|
let paths = nu_engine::env::path_str(engine_state, stack, call.head)?;
|
||||||
let Some(executable) = which(expanded_name, &paths, cwd.as_ref()) else {
|
let Some(executable) = which(expanded_name, &paths, cwd.as_ref()) else {
|
||||||
return Err(command_not_found(&name_str, call.head, engine_state, stack));
|
return Err(command_not_found(
|
||||||
|
&name_str,
|
||||||
|
call.head,
|
||||||
|
engine_state,
|
||||||
|
stack,
|
||||||
|
&cwd,
|
||||||
|
));
|
||||||
};
|
};
|
||||||
executable
|
executable
|
||||||
};
|
};
|
||||||
@ -371,6 +377,7 @@ pub fn command_not_found(
|
|||||||
span: Span,
|
span: Span,
|
||||||
engine_state: &EngineState,
|
engine_state: &EngineState,
|
||||||
stack: &mut Stack,
|
stack: &mut Stack,
|
||||||
|
cwd: &AbsolutePath,
|
||||||
) -> ShellError {
|
) -> ShellError {
|
||||||
// Run the `command_not_found` hook if there is one.
|
// Run the `command_not_found` hook if there is one.
|
||||||
if let Some(hook) = &stack.get_config(engine_state).hooks.command_not_found {
|
if let Some(hook) = &stack.get_config(engine_state).hooks.command_not_found {
|
||||||
@ -481,12 +488,12 @@ pub fn command_not_found(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If we find a file, it's likely that the user forgot to set permissions
|
// If we find a file, it's likely that the user forgot to set permissions
|
||||||
if Path::new(name).is_file() {
|
if cwd.join(name).is_file() {
|
||||||
return ShellError::ExternalCommand {
|
return ShellError::ExternalCommand {
|
||||||
label: format!("Command `{name}` not found"),
|
label: format!("Command `{name}` not found"),
|
||||||
help: format!("`{name}` refers to a file that is not executable. Did you forget to set execute permissions?"),
|
help: format!("`{name}` refers to a file that is not executable. Did you forget to set execute permissions?"),
|
||||||
span,
|
span,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// We found nothing useful. Give up and return a generic error message.
|
// We found nothing useful. Give up and return a generic error message.
|
||||||
|
@ -68,7 +68,7 @@ fn pre_prompt_hook(code: &str) -> String {
|
|||||||
format!(
|
format!(
|
||||||
"$env.config = {{
|
"$env.config = {{
|
||||||
hooks: {{
|
hooks: {{
|
||||||
pre_prompt: {code}
|
pre_prompt: [{code}]
|
||||||
}}
|
}}
|
||||||
}}"
|
}}"
|
||||||
)
|
)
|
||||||
@ -78,9 +78,9 @@ fn pre_prompt_hook_code(code: &str) -> String {
|
|||||||
format!(
|
format!(
|
||||||
"$env.config = {{
|
"$env.config = {{
|
||||||
hooks: {{
|
hooks: {{
|
||||||
pre_prompt: {{
|
pre_prompt: [{{
|
||||||
code: {code}
|
code: {code}
|
||||||
}}
|
}}]
|
||||||
}}
|
}}
|
||||||
}}"
|
}}"
|
||||||
)
|
)
|
||||||
@ -90,7 +90,7 @@ fn pre_execution_hook(code: &str) -> String {
|
|||||||
format!(
|
format!(
|
||||||
"$env.config = {{
|
"$env.config = {{
|
||||||
hooks: {{
|
hooks: {{
|
||||||
pre_execution: {code}
|
pre_execution: [{code}]
|
||||||
}}
|
}}
|
||||||
}}"
|
}}"
|
||||||
)
|
)
|
||||||
@ -100,9 +100,9 @@ fn pre_execution_hook_code(code: &str) -> String {
|
|||||||
format!(
|
format!(
|
||||||
"$env.config = {{
|
"$env.config = {{
|
||||||
hooks: {{
|
hooks: {{
|
||||||
pre_execution: {{
|
pre_execution: [{{
|
||||||
code: {code}
|
code: {code}
|
||||||
}}
|
}}]
|
||||||
}}
|
}}
|
||||||
}}"
|
}}"
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user