nushell/crates/nu-engine/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
..
call_ext.rs make the ansi command const (#11682) 2024-01-30 16:09:43 -06:00
column.rs Use Record's public API in a bunch of places (#10927) 2023-11-08 14:24:00 +01:00
documentation.rs Spread operator in record literals (#11144) 2023-11-29 18:31:31 +01:00
env.rs Convert Shellerror::GenericError to named fields (#11230) 2023-12-07 00:40:03 +01:00
eval.rs Support redirect stderr and stdout+stderr with a pipe (#11708) 2024-02-09 01:30:46 +08:00
glob_from.rs Unify glob behavior on open, rm, cp-old, mv, umv, cp and du commands (#11621) 2024-01-26 21:57:35 +08:00
lib.rs Allow operator in constants (#10212) 2023-09-05 16:35:58 +02:00
scope.rs Fix panic in rotate; Add safe record creation function (#11718) 2024-02-03 13:23:16 +02:00