Support redirect stderr and stdout+stderr with a pipe#11708
Support redirect stderr and stdout+stderr with a pipe#11708WindSoilder merged 12 commits intonushell:mainfrom
Conversation
|
I'm OK with it because it fills in missing functionality. The redirection syntax is becoming quite complex at this point. It would be good to have an overview of all possible ways, including But as I said, we should land this PR because it's consistent with our current style. |
…uired, is_redirect_stderr_required functions 2. handles for cases: cmd o> /dev/null e>| next cmd
…edirect_stdout rules
|
Thanks for feedback! there is one more thing which is unclear to me. Currently
|
Maybe we should, to make it consistent with |
|
Great, it'll be nice to be able to redirect stderr. Correct me if I'm wrong, but isn't |
|
@IanManske Yup,
I think it's So they would be idential:
|
Sorry, I misread the PR 😅 I also wrongly thought that |
Yeah, it's ignored :) |
|
Let's go and try it |
|
Thank you for continuing to work on redirection! |
# Description Close: nushell#9673 Close: nushell#8277 Close: nushell#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 nushell#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 nushell#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.
Description
Close: #9673
Close: #8277
Close: #10944
This pr introduces the following syntax:
e>|, pipe stderr to next command. Example:$env.FOO=bar nu --testbin echo_env_stderr FOO e>| str lengtho+e>|ande+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 lengthNote: 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 commandsThis can help us to avoid some strange issues like the following:
$env.FOO=bar (nu --testbin echo_env_stderr FOO) e>| str lengthWhich 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.