Raise error when using o>| pipe (#13323)

# Description
From the feedbacks from @amtoine , it's good to make nushell shows error
for `o>|` syntax.

# User-Facing Changes
## Before
```nushell
'foo' o>| print                                                                                                                                                                                                                     07/09/2024 06:44:23 AM
Error: nu::parser::parse_mismatch

  × Parse mismatch during operation.
   ╭─[entry #6:1:9]
 1 │ 'foo' o>| print
   ·         ┬
   ·         ╰── expected redirection target
```

## After
```nushell
'foo' o>| print                                                                                                                                                                                                                     07/09/2024 06:47:26 AM
Error: nu::parser::parse_mismatch

  × Parse mismatch during operation.
   ╭─[entry #1:1:7]
 1 │ 'foo' o>| print
   ·       ─┬─
   ·        ╰── expected `|`.  Redirection stdout to pipe is the same as piping directly.
   ╰────
```

# Tests + Formatting
Added one test

---------

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
This commit is contained in:
Wind
2024-07-09 20:11:25 +08:00
committed by GitHub
parent e98b2ceb8c
commit 1964dacaef
2 changed files with 46 additions and 15 deletions

View File

@@ -1161,3 +1161,11 @@ fn command_not_found_error_shows_not_found_2() {
&& actual.err.contains("Did you mean `for`?")
);
}
#[test]
fn error_on_out_greater_pipe() {
let actual = nu!(r#""foo" o>| print"#);
assert!(actual
.err
.contains("Redirecting stdout to a pipe is the same as normal piping"))
}