mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 14:15:53 +02:00
Make Hooks
fields non-optional to match the new config defaults (#14345)
# Description Follow up to #14341. Changes the fields of `Hooks` to `Vec` or `Hashmap` to match the new config defaults. # User-Facing Changes Mostly the same as #14341. `pre_prompt` and `pre_execution` must now be a list, and `env_change` must be a record.
This commit is contained in:
@ -45,6 +45,7 @@ On Windows based systems, Nushell will wait for the command to finish and then e
|
||||
call.head,
|
||||
engine_state,
|
||||
stack,
|
||||
&cwd,
|
||||
));
|
||||
};
|
||||
executable
|
||||
|
@ -1,6 +1,6 @@
|
||||
use nu_cmd_base::hook::eval_hook;
|
||||
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_system::ForegroundChild;
|
||||
use nu_utils::IgnoreCaseExt;
|
||||
@ -126,7 +126,13 @@ impl Command for External {
|
||||
// effect if it's an absolute path already
|
||||
let paths = nu_engine::env::path_str(engine_state, stack, call.head)?;
|
||||
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
|
||||
};
|
||||
@ -433,6 +439,7 @@ pub fn command_not_found(
|
||||
span: Span,
|
||||
engine_state: &EngineState,
|
||||
stack: &mut Stack,
|
||||
cwd: &AbsolutePath,
|
||||
) -> ShellError {
|
||||
// Run the `command_not_found` hook if there is one.
|
||||
if let Some(hook) = &stack.get_config(engine_state).hooks.command_not_found {
|
||||
@ -543,12 +550,12 @@ pub fn command_not_found(
|
||||
}
|
||||
|
||||
// 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 {
|
||||
label: format!("Command `{name}` not found"),
|
||||
help: format!("`{name}` refers to a file that is not executable. Did you forget to set execute permissions?"),
|
||||
span,
|
||||
};
|
||||
label: format!("Command `{name}` not found"),
|
||||
help: format!("`{name}` refers to a file that is not executable. Did you forget to set execute permissions?"),
|
||||
span,
|
||||
};
|
||||
}
|
||||
|
||||
// We found nothing useful. Give up and return a generic error message.
|
||||
|
Reference in New Issue
Block a user