-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Permit combining stdout/stderr as streams to external command behind pipe #9673
Comments
You could try the
|
|
Thank you for the clarification! The intent behind the example given is to receive streamed data to get a nice visualization of the progress =) |
Considering the replies received so far, should this become a feature request instead? |
IMO it should be, AFAIK there is no straight way to do this(not sure whether it is possible or not) and it is most common in unix systems |
@x10an14 |
done |
thanks @x10an14 😊 |
I had the same problem just now and went with |
Can you link/reference/document the |
https://www.nushell.sh/commands/docs/run-external.html I think this is the PR where it was added in April. |
The run-external --redirect-combine nix flake check "--log-format" internal-json "-v" | nom --json While this is of course much better than my previous "use bash" solution, would Dunno how, but force ordering of flags for |
This is how it looks like if I don't quoute all flags sent to wrapped binary/command:
|
A helper to prevent def --wrapped run [cmd ...args] { run-external --redirect-combine $cmd $args } For the convenience you give up the ability to control the flags given to A more principled solution would be to teach Nu how to use |
# 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.
# 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.
Question
Given command
foo
, which outputs both stdout and stderr, how can I pipe both of stdout and stderr fromfoo
intobar
through a pipe?Ref these (non-exhaustive list of) alternatives which achieve this in bash:
Additional context and details
The only way for me to automate checking of my
flake.nix
checks (in a nice graphical output) in Nushell when usingnom
now is this arcane invocation:Feels weird that I cannot do the equivalent of "combine outputs and redirect them through pipe" in Nushell =S
The text was updated successfully, but these errors were encountered: