You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Permit combining stdout/stderr as streams to external command behind pipe #9673
A:redirection-pipeAll related to redirection to files or more complex pipelines with STDERRA:streamingIssues related to streaming data (or collecting data when it should be streamed)category:enhancementNew feature or request
changed the title [-]How can I redirect stdout and stderr (combined) as stdin through a pipe?[/-][+]How can I redirect stdout and stderr (combined as a stream) as stdin through a pipe?[/+]on Jul 14, 2023
changed the title [-]How can I redirect stdout and stderr (combined as a stream) as stdin through a pipe?[/-][+]Permit combining stdout/stderr as streams to external command behind pipe[/+]on Jul 14, 2023
The run-external --redirect-combine tip works! But only if I quote each and every word starting with a hyphen (read: flag) like so (it seems):
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 run-external (by its intent and nature) not be better suited to pass all inputs starting with - to the command its encompassing/running?
Dunno how, but force ordering of flags for run-external to come before the wrapped command maybe?
For the convenience you give up the ability to control the flags given to run-external, but get an experience much closer to how ^ works. Each flag you define on run can't be passed through without quoting, but using the wrapper limits that to exclusively just the automatic --help(-h) switch.
A more principled solution would be to teach Nu how to use -- to delineate the end of flags and that all following args are rest arguments. The best solution would probably be to be able to combine "retroactively" and do something like ^external | combine like you can do ^external | complete.
A:redirection-pipeAll related to redirection to files or more complex pipelines with STDERRA:streamingIssues related to streaming data (or collecting data when it should be streamed)category:enhancementNew feature or request
Activity
fdncred commentedon Jul 13, 2023
You could try the
completecommand but it won't interleave stderr and stdout.hardfau1t commentedon Jul 14, 2023
[-]How can I redirect stdout and stderr (combined) as stdin through a pipe?[/-][+]How can I redirect stdout and stderr (combined as a stream) as stdin through a pipe?[/+]x10an14 commentedon Jul 14, 2023
Thank you for the clarification! The intent behind the example given is to receive streamed data to get a nice visualization of the progress =)
x10an14 commentedon Jul 14, 2023
Considering the replies received so far, should this become a feature request instead?
hardfau1t commentedon Jul 14, 2023
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
amtoine commentedon Jul 14, 2023
@x10an14
you can just update the title and the body of this issue to make it a feature request 😉
[-]How can I redirect stdout and stderr (combined as a stream) as stdin through a pipe?[/-][+]Permit combining stdout/stderr as streams to external command behind pipe[/+]x10an14 commentedon Jul 14, 2023
Will you replace the question label/add the feature flag label? =)
fdncred commentedon Jul 15, 2023
done
amtoine commentedon Jul 15, 2023
thanks @x10an14 😊
haitemura commentedon Aug 14, 2023
I had the same problem just now and went with
run-external --redirect-combine foo | bar. But a shorter way to do this would help.x10an14 commentedon Aug 14, 2023
Can you link/reference/document the
redirect-combineflag? And never heard of it or it's command. I have yet to check if it's a built-infdncred commentedon Aug 14, 2023
https://www.nushell.sh/commands/docs/run-external.html
I think this is the PR where it was added in April.
#8918
x10an14 commentedon Aug 16, 2023
The
run-external --redirect-combinetip works! But only if I quote each and every word starting with a hyphen (read: flag) like so (it seems):While this is of course much better than my previous "use bash" solution, would
run-external(by its intent and nature) not be better suited to pass all inputs starting with-to the command its encompassing/running?Dunno how, but force ordering of flags for
run-externalto come before the wrapped command maybe?x10an14 commentedon Aug 16, 2023
This is how it looks like if I don't quoute all flags sent to wrapped binary/command:
CAD97 commentedon Oct 23, 2023
A helper to prevent
run-externalfrom trying to interpret your command's flags:For the convenience you give up the ability to control the flags given to
run-external, but get an experience much closer to how^works. Each flag you define onruncan't be passed through without quoting, but using the wrapper limits that to exclusively just the automatic--help(-h)switch.A more principled solution would be to teach Nu how to use
--to delineate the end of flags and that all following args are rest arguments. The best solution would probably be to be able to combine "retroactively" and do something like^external | combinelike you can do^external | complete.Support redirect stderr and stdout+stderr with a pipe (#11708)
Support redirect stderr and stdout+stderr with a pipe (nushell#11708)