mirror of
https://github.com/nushell/nushell.git
synced 2025-05-06 19:14:25 +02:00
remove -s, -p in do (#15456)
# Description Closes #15450 # User-Facing Changes do can't use `-s`, `-p` after this pr # Tests + Formatting Removed 3 tests. # After Submitting NaN
This commit is contained in:
parent
f39e5b3f37
commit
43f9ec295f
@ -31,16 +31,6 @@ impl Command for Do {
|
|||||||
"ignore errors as the closure runs",
|
"ignore errors as the closure runs",
|
||||||
Some('i'),
|
Some('i'),
|
||||||
)
|
)
|
||||||
.switch(
|
|
||||||
"ignore-shell-errors",
|
|
||||||
"ignore shell errors as the closure runs",
|
|
||||||
Some('s'),
|
|
||||||
)
|
|
||||||
.switch(
|
|
||||||
"ignore-program-errors",
|
|
||||||
"ignore external program errors as the closure runs",
|
|
||||||
Some('p'),
|
|
||||||
)
|
|
||||||
.switch(
|
.switch(
|
||||||
"capture-errors",
|
"capture-errors",
|
||||||
"catch errors as the closure runs, and return them",
|
"catch errors as the closure runs, and return them",
|
||||||
@ -71,36 +61,6 @@ impl Command for Do {
|
|||||||
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_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
|
|
||||||
|| call.has_flag(engine_state, caller_stack, "ignore-program-errors")?;
|
|
||||||
let capture_errors = call.has_flag(engine_state, caller_stack, "capture-errors")?;
|
let capture_errors = call.has_flag(engine_state, caller_stack, "capture-errors")?;
|
||||||
let has_env = call.has_flag(engine_state, caller_stack, "env")?;
|
let has_env = call.has_flag(engine_state, caller_stack, "env")?;
|
||||||
|
|
||||||
@ -206,7 +166,7 @@ impl Command for Do {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(PipelineData::ByteStream(mut stream, metadata))
|
Ok(PipelineData::ByteStream(mut stream, metadata))
|
||||||
if ignore_program_errors
|
if ignore_all_errors
|
||||||
&& !matches!(
|
&& !matches!(
|
||||||
caller_stack.stdout(),
|
caller_stack.stdout(),
|
||||||
OutDest::Pipe | OutDest::PipeSeparate | OutDest::Value
|
OutDest::Pipe | OutDest::PipeSeparate | OutDest::Value
|
||||||
@ -218,10 +178,10 @@ impl Command for Do {
|
|||||||
}
|
}
|
||||||
Ok(PipelineData::ByteStream(stream, metadata))
|
Ok(PipelineData::ByteStream(stream, metadata))
|
||||||
}
|
}
|
||||||
Ok(PipelineData::Value(Value::Error { .. }, ..)) | Err(_) if ignore_shell_errors => {
|
Ok(PipelineData::Value(Value::Error { .. }, ..)) | Err(_) if ignore_all_errors => {
|
||||||
Ok(PipelineData::empty())
|
Ok(PipelineData::empty())
|
||||||
}
|
}
|
||||||
Ok(PipelineData::ListStream(stream, metadata)) if ignore_shell_errors => {
|
Ok(PipelineData::ListStream(stream, metadata)) if ignore_all_errors => {
|
||||||
let stream = stream.map(move |value| {
|
let stream = stream.map(move |value| {
|
||||||
if let Value::Error { .. } = value {
|
if let Value::Error { .. } = value {
|
||||||
Value::nothing(head)
|
Value::nothing(head)
|
||||||
|
@ -40,22 +40,6 @@ fn do_with_semicolon_break_on_failed_external() {
|
|||||||
assert_eq!(actual.out, "");
|
assert_eq!(actual.out, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn ignore_shell_errors_works_for_external_with_semicolon() {
|
|
||||||
let actual = nu!(r#"do -s { open asdfasdf.txt }; "text""#);
|
|
||||||
|
|
||||||
assert!(actual.err.contains("Deprecated option"));
|
|
||||||
assert_eq!(actual.out, "text");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn ignore_program_errors_works_for_external_with_semicolon() {
|
|
||||||
let actual = nu!(r#"do -p { nu -n -c 'exit 1' }; "text""#);
|
|
||||||
|
|
||||||
assert!(actual.err.contains("Deprecated option"));
|
|
||||||
assert_eq!(actual.out, "text");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ignore_error_should_work_for_external_command() {
|
fn ignore_error_should_work_for_external_command() {
|
||||||
let actual = nu!(r#"do -i { nu --testbin fail asdf }; echo post"#);
|
let actual = nu!(r#"do -i { nu --testbin fail asdf }; echo post"#);
|
||||||
@ -76,11 +60,3 @@ fn run_closure_with_it_using() {
|
|||||||
assert!(actual.err.is_empty());
|
assert!(actual.err.is_empty());
|
||||||
assert_eq!(actual.out, "3");
|
assert_eq!(actual.out, "3");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn waits_for_external() {
|
|
||||||
let actual = nu!(r#"do -p { nu -c 'sleep 1sec; print before; exit 1'}; print after"#);
|
|
||||||
|
|
||||||
assert!(actual.err.contains("Deprecated option"));
|
|
||||||
assert_eq!(actual.out, "beforeafter");
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user