nushell/crates/nu-parser/src
Wind 58c6fea60b
Support redirect stderr and stdout+stderr with a pipe (#11708)
# Description
Close: #9673
Close: #8277
Close: #10944

This pr introduces the following syntax:
1. `e>|`, pipe stderr to next command. Example: `$env.FOO=bar nu
--testbin echo_env_stderr FOO e>| str length`
2. `o+e>|` and `e+o>|`, pipe both stdout and stderr to next command,
example: `$env.FOO=bar nu --testbin echo_env_mixed out-err FOO FOO e+o>|
str length`

Note: it only works for external commands. ~There is no different for
internal commands, that is, the following three commands do the same
things:~ Edit: it raises errors if we want to pipes for internal
commands
``` 
❯ ls e>| str length
Error:   × `e>|` only works with external streams
   ╭─[entry #1:1:1]
 1 │ ls e>| str length
   ·    ─┬─
   ·     ╰── `e>|` only works on external streams
   ╰────

❯ ls e+o>| str length
Error:   × `o+e>|` only works with external streams
   ╭─[entry #2:1:1]
 1 │ ls e+o>| str length
   ·    ──┬──
   ·      ╰── `o+e>|` only works on external streams
   ╰────
```

This can help us to avoid some strange issues like the following:

`$env.FOO=bar (nu --testbin echo_env_stderr FOO) e>| str length`

Which is hard to understand and hard to explain to users.

# User-Facing Changes
Nan

# Tests + Formatting
To be done

# After Submitting
Maybe update documentation about these syntax.
2024-02-09 01:30:46 +08:00
..
deparse.rs update deps calamine and quick-xml (#11582) 2024-01-19 12:23:51 -06:00
flatten.rs Support redirect stderr and stdout+stderr with a pipe (#11708) 2024-02-09 01:30:46 +08:00
known_external.rs Allow spreading arguments to commands (#11289) 2023-12-28 15:43:20 +08:00
lex.rs Support redirect stderr and stdout+stderr with a pipe (#11708) 2024-02-09 01:30:46 +08:00
lib.rs Move SyntaxShape specifier parsing into own file (#10448) 2023-10-05 23:31:40 +02:00
lite_parser.rs Support redirect stderr and stdout+stderr with a pipe (#11708) 2024-02-09 01:30:46 +08:00
parse_keywords.rs Support redirect stderr and stdout+stderr with a pipe (#11708) 2024-02-09 01:30:46 +08:00
parse_patterns.rs Remove Expr::MatchPattern (#11367) 2023-12-20 18:52:28 +01:00
parse_shape_specs.rs Move SyntaxShape specifier parsing into own file (#10448) 2023-10-05 23:31:40 +02:00
parser.rs Support redirect stderr and stdout+stderr with a pipe (#11708) 2024-02-09 01:30:46 +08:00
parser_path.rs Add virtual path abstraction layer (#9245) 2023-05-23 23:48:50 +03:00
type_check.rs Allow string to copmpare with another string (#11590) 2024-01-21 07:43:40 -06:00