From e5bd9926590ffacd9be96293bc493e16fa426299 Mon Sep 17 00:00:00 2001 From: WindSoilder Date: Tue, 19 Nov 2024 20:52:51 +0800 Subject: [PATCH] deprecate --ignore-shell-errors and --ignore-program-errors in do command --- crates/nu-cmd-lang/src/core_commands/do_.rs | 27 +++++++++++++++++++ .../nu-utils/src/sample_config/default_env.nu | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/crates/nu-cmd-lang/src/core_commands/do_.rs b/crates/nu-cmd-lang/src/core_commands/do_.rs index 5f1b42cb66..0f161e6d35 100644 --- a/crates/nu-cmd-lang/src/core_commands/do_.rs +++ b/crates/nu-cmd-lang/src/core_commands/do_.rs @@ -69,6 +69,33 @@ impl Command for Do { let block: Closure = call.req(engine_state, caller_stack, 0)?; let rest: Vec = call.rest(engine_state, caller_stack, 1)?; 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 || call.has_flag(engine_state, caller_stack, "ignore-shell-errors")?; let ignore_program_errors = ignore_all_errors diff --git a/crates/nu-utils/src/sample_config/default_env.nu b/crates/nu-utils/src/sample_config/default_env.nu index fb527dc112..8f68424ac5 100644 --- a/crates/nu-utils/src/sample_config/default_env.nu +++ b/crates/nu-utils/src/sample_config/default_env.nu @@ -3,7 +3,7 @@ # version = "0.100.1" 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 '' => '~' $relative_pwd => ([~ $relative_pwd] | path join)