mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 14:40:06 +02:00
Add --redirect-combine option to run-external (#8918)
# Description Add option that combines both output streams to the `run-external` command. This allows you to do something like this: ```nushell let res = do -i { run-external --redirect-combine <command that prints to stdout and stderr> } | complete if $res.exit_code != 0 { # Only print output when command has failed. print "The command has failed, these are the logs:" print $res.stdout } ``` # User-Facing Changes No breaking changes, just an extra option. # Tests + Formatting Added a test that checks the new option # After Submitting <!-- If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. --> Co-authored-by: Jelle Besseling <jelle@bigbridge.nl>
This commit is contained in:
@ -320,3 +320,18 @@ fn quotes_trimmed_when_shelling_out() {
|
||||
|
||||
assert_eq!(actual.out, "foo");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn redirect_combine() {
|
||||
Playground::setup("redirect_combine", |dirs, _| {
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
r#"
|
||||
run-external --redirect-combine sh [-c 'echo Foo; echo >&2 Bar']
|
||||
"#
|
||||
));
|
||||
|
||||
// Lines are collapsed in the nu! macro
|
||||
assert_eq!(actual.out, "FooBar");
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user