mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 14:37:59 +02:00
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:
@ -383,7 +383,21 @@ pub fn eval_expression_with_input(
|
||||
}
|
||||
};
|
||||
|
||||
Ok(might_consume_external_result(input))
|
||||
// Given input is PipelineData::ExternalStream
|
||||
// `might_consume_external_result` will consume `stderr` stream if `stdout` is empty.
|
||||
// it's not intended if user want to redirect stderr message.
|
||||
//
|
||||
// e.g:
|
||||
// 1. cargo check e>| less
|
||||
// 2. cargo check e> result.txt
|
||||
//
|
||||
// In these two cases, stdout will be empty, but nushell shouldn't consume the `stderr`
|
||||
// stream it needs be passed to next command.
|
||||
if !redirect_stderr {
|
||||
Ok(might_consume_external_result(input))
|
||||
} else {
|
||||
Ok((input, false))
|
||||
}
|
||||
}
|
||||
|
||||
// Try to catch and detect if external command runs to failed.
|
||||
|
Reference in New Issue
Block a user