don't allow break in each and items command

This commit is contained in:
WindSoilder 2024-07-17 15:01:30 +08:00
parent b66671d339
commit e1ef110169
3 changed files with 0 additions and 18 deletions

View File

@ -132,8 +132,6 @@ with 'transpose' first."#
Ok(data) => Some(data.into_value(head).unwrap_or_else(|err| {
Value::error(chain_error_with_input(err, is_error, span), span)
})),
Err(ShellError::Continue { span }) => Some(Value::nothing(span)),
Err(ShellError::Break { .. }) => None,
Err(error) => {
let error = chain_error_with_input(error, is_error, span);
Some(Value::error(error, span))
@ -149,10 +147,6 @@ with 'transpose' first."#
.map_while(move |value| {
let value = match value {
Ok(value) => value,
Err(ShellError::Continue { span }) => {
return Some(Value::nothing(span))
}
Err(ShellError::Break { .. }) => return None,
Err(err) => return Some(Value::error(err, head)),
};
@ -163,8 +157,6 @@ with 'transpose' first."#
.and_then(|data| data.into_value(head))
{
Ok(value) => Some(value),
Err(ShellError::Continue { span }) => Some(Value::nothing(span)),
Err(ShellError::Break { .. }) => None,
Err(error) => {
let error = chain_error_with_input(error, is_error, span);
Some(Value::error(error, span))

View File

@ -60,7 +60,6 @@ impl Command for Items {
match result {
Ok(value) => Some(value),
Err(ShellError::Break { .. }) => None,
Err(err) => {
let err = chain_error_with_input(err, false, span);
Some(Value::error(err, head))

View File

@ -15,12 +15,3 @@ fn break_while_loop() {
assert_eq!(actual.out, "hello");
}
#[test]
fn break_each() {
let actual = nu!("
[1, 2, 3, 4, 5] | each {|x| if $x > 3 { break }; $x} | math sum
");
assert_eq!(actual.out, "6");
}