make stderr works for failed external command (#11914)

# Description
Fixes: #11913

When running external command, nushell shouldn't consumes stderr
messages, if user want to redirect stderr.

# User-Facing Changes
NaN

# Tests + Formatting
Done

# After Submitting
NaN
This commit is contained in:
Wind
2024-02-21 21:15:05 +08:00
committed by GitHub
parent 6e590fe0a2
commit 1058707a29
5 changed files with 45 additions and 1 deletions

View File

@@ -269,6 +269,7 @@ fn main() -> Result<()> {
match testbin.item.as_str() {
"echo_env" => test_bins::echo_env(true),
"echo_env_stderr" => test_bins::echo_env(false),
"echo_env_stderr_fail" => test_bins::echo_env_and_fail(false),
"echo_env_mixed" => test_bins::echo_env_mixed(),
"cococo" => test_bins::cococo(),
"meow" => test_bins::meow(),

View File

@@ -16,6 +16,11 @@ pub fn echo_env(to_stdout: bool) {
}
}
pub fn echo_env_and_fail(to_stdout: bool) {
echo_env(to_stdout);
fail();
}
fn echo_one_env(arg: &str, to_stdout: bool) {
if let Ok(v) = std::env::var(arg) {
if to_stdout {