deprecate --ignore-shell-errors and --ignore-program-errors in do command

This commit is contained in:
WindSoilder
2024-11-19 20:52:51 +08:00
parent 13ce9e4f64
commit e5bd992659
2 changed files with 28 additions and 1 deletions

View File

@ -69,6 +69,33 @@ impl Command for Do {
let block: Closure = call.req(engine_state, caller_stack, 0)?; let block: Closure = call.req(engine_state, caller_stack, 0)?;
let rest: Vec<Value> = call.rest(engine_state, caller_stack, 1)?; let rest: Vec<Value> = call.rest(engine_state, caller_stack, 1)?;
let ignore_all_errors = call.has_flag(engine_state, caller_stack, "ignore-errors")?; let ignore_all_errors = call.has_flag(engine_state, caller_stack, "ignore-errors")?;
if call.has_flag(engine_state, caller_stack, "ignore-shell-errors")? {
nu_protocol::report_shell_error(
engine_state,
&ShellError::GenericError {
error: "Deprecated option".into(),
msg: "`--ignore-shell-errors` is deprecated and will be removed in 0.102.0."
.into(),
span: Some(call.head),
help: Some("Please use the `--ignore-errors(-i)`".into()),
inner: vec![],
},
);
}
if call.has_flag(engine_state, caller_stack, "ignore-program-errors")? {
nu_protocol::report_shell_error(
engine_state,
&ShellError::GenericError {
error: "Deprecated option".into(),
msg: "`--ignore-program-errors` is deprecated and will be removed in 0.102.0."
.into(),
span: Some(call.head),
help: Some("Please use the `--ignore-errors(-i)`".into()),
inner: vec![],
},
);
}
let ignore_shell_errors = ignore_all_errors let ignore_shell_errors = ignore_all_errors
|| call.has_flag(engine_state, caller_stack, "ignore-shell-errors")?; || call.has_flag(engine_state, caller_stack, "ignore-shell-errors")?;
let ignore_program_errors = ignore_all_errors let ignore_program_errors = ignore_all_errors

View File

@ -3,7 +3,7 @@
# version = "0.100.1" # version = "0.100.1"
def create_left_prompt [] { def create_left_prompt [] {
let dir = match (do --ignore-shell-errors { $env.PWD | path relative-to $nu.home-path }) { let dir = match (do --ignore-errors { $env.PWD | path relative-to $nu.home-path }) {
null => $env.PWD null => $env.PWD
'' => '~' '' => '~'
$relative_pwd => ([~ $relative_pwd] | path join) $relative_pwd => ([~ $relative_pwd] | path join)