diff --git a/crates/nu-cmd-lang/src/core_commands/do_.rs b/crates/nu-cmd-lang/src/core_commands/do_.rs index 5f1b42cb66..81ea22ad39 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_warning( + 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_warning( + 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 @@ -208,16 +235,6 @@ impl Command for Do { example: r#"do --ignore-errors { thisisnotarealcommand }"#, result: None, }, - Example { - description: "Run the closure and ignore shell errors", - example: r#"do --ignore-shell-errors { thisisnotarealcommand }"#, - result: None, - }, - Example { - description: "Run the closure and ignore external program errors", - example: r#"do --ignore-program-errors { nu --commands 'exit 1' }; echo "I'll still run""#, - result: None, - }, Example { description: "Abort the pipeline if a program returns a non-zero exit code", example: r#"do --capture-errors { nu --commands 'exit 1' } | myscarycommand"#, diff --git a/crates/nu-command/tests/commands/do_.rs b/crates/nu-command/tests/commands/do_.rs index bbce5648db..1a2258cf9c 100644 --- a/crates/nu-command/tests/commands/do_.rs +++ b/crates/nu-command/tests/commands/do_.rs @@ -44,7 +44,7 @@ fn do_with_semicolon_break_on_failed_external() { fn ignore_shell_errors_works_for_external_with_semicolon() { let actual = nu!(r#"do -s { open asdfasdf.txt }; "text""#); - assert_eq!(actual.err, ""); + assert!(actual.err.contains("Deprecated option")); assert_eq!(actual.out, "text"); } @@ -52,7 +52,7 @@ fn ignore_shell_errors_works_for_external_with_semicolon() { fn ignore_program_errors_works_for_external_with_semicolon() { let actual = nu!(r#"do -p { nu -n -c 'exit 1' }; "text""#); - assert_eq!(actual.err, ""); + assert!(actual.err.contains("Deprecated option")); assert_eq!(actual.out, "text"); } @@ -80,6 +80,7 @@ fn run_closure_with_it_using() { #[test] fn waits_for_external() { let actual = nu!(r#"do -p { nu -c 'sleep 1sec; print before; exit 1'}; print after"#); - assert!(actual.err.is_empty()); + + assert!(actual.err.contains("Deprecated option")); assert_eq!(actual.out, "beforeafter"); } diff --git a/crates/nu-utils/src/default_files/default_env.nu b/crates/nu-utils/src/default_files/default_env.nu index 498c9670b3..1f702d984b 100644 --- a/crates/nu-utils/src/default_files/default_env.nu +++ b/crates/nu-utils/src/default_files/default_env.nu @@ -4,7 +4,7 @@ # version = "0.100.1" $env.PROMPT_COMMAND = {|| - let dir = match (do --ignore-shell-errors { $env.PWD | path relative-to $nu.home-path }) { + let dir = match (do -i { $env.PWD | path relative-to $nu.home-path }) { null => $env.PWD '' => '~' $relative_pwd => ([~ $relative_pwd] | path join)