forked from extern/nushell
redirection: fix internal commands error with o+e>
redirection (#10816)
# Description Currently the following command is broken: ```nushell echo a o+e> 1.txt ``` It's because we don't redirect output of `echo` command. This pr is trying to fix it.
This commit is contained in:
parent
d93315d8f5
commit
f35741d50e
@ -216,12 +216,14 @@ fn redirect_support_variable() {
|
|||||||
|
|
||||||
assert!(output.out.contains("hello"));
|
assert!(output.out.contains("hello"));
|
||||||
|
|
||||||
let output = nu!(
|
nu!(
|
||||||
cwd: dirs.test(),
|
cwd: dirs.test(),
|
||||||
"let x = 'tmp_file'; echo 'hello' out+err> $x; open tmp_file"
|
"let x = 'tmp_file'; echo 'hello there' out+err> $x; open tmp_file"
|
||||||
);
|
);
|
||||||
|
// check for stdout redirection file.
|
||||||
assert!(output.out.contains("hello"));
|
let expected_out_file = dirs.test().join("tmp_file");
|
||||||
|
let actual = file_contents(expected_out_file);
|
||||||
|
assert!(actual.contains("hello there"));
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -925,15 +925,18 @@ fn eval_element_with_input(
|
|||||||
*is_subexpression,
|
*is_subexpression,
|
||||||
)?
|
)?
|
||||||
}
|
}
|
||||||
_ => eval_element_with_input(
|
_ => {
|
||||||
engine_state,
|
// we need to redirect output, so the result can be saved and pass to `save` command.
|
||||||
stack,
|
eval_element_with_input(
|
||||||
&PipelineElement::Expression(*cmd_span, cmd_exp.clone()),
|
engine_state,
|
||||||
input,
|
stack,
|
||||||
redirect_stdout,
|
&PipelineElement::Expression(*cmd_span, cmd_exp.clone()),
|
||||||
redirect_stderr,
|
input,
|
||||||
)
|
true,
|
||||||
.map(|x| x.0)?,
|
redirect_stderr,
|
||||||
|
)
|
||||||
|
.map(|x| x.0)?
|
||||||
|
}
|
||||||
};
|
};
|
||||||
eval_element_with_input(
|
eval_element_with_input(
|
||||||
engine_state,
|
engine_state,
|
||||||
|
Loading…
Reference in New Issue
Block a user