mirror of
https://github.com/nushell/nushell.git
synced 2025-08-13 20:27:15 +02:00
Fix try
not working with let
, etc. (#13885)
# Description Partialy addresses #13868. `try` does not catch non-zero exit code errors from the last command in a pipeline if the result is assigned to a variable using `let` (or `mut`). This was fixed by adding a new `OutDest::Value` case. This is used when the pipeline is in a "value" position. I.e., it will be collected into a value. This ended up replacing most of the usages of `OutDest::Capture`. So, this PR also renames `OutDest::Capture` to `OutDest::PipeSeparate` to better fit the few remaining use cases for it. # User-Facing Changes Bug fix. # Tests + Formatting Added two tests.
This commit is contained in:
@ -190,8 +190,8 @@ impl<'a> PluginExecutionContext for PluginExecutionCommandContext<'a> {
|
||||
.reset_pipes();
|
||||
|
||||
let stack = &mut stack.push_redirection(
|
||||
redirect_stdout.then_some(Redirection::Pipe(OutDest::Capture)),
|
||||
redirect_stderr.then_some(Redirection::Pipe(OutDest::Capture)),
|
||||
redirect_stdout.then_some(Redirection::Pipe(OutDest::PipeSeparate)),
|
||||
redirect_stderr.then_some(Redirection::Pipe(OutDest::PipeSeparate)),
|
||||
);
|
||||
|
||||
// Set up the positional arguments
|
||||
@ -239,8 +239,8 @@ impl<'a> PluginExecutionContext for PluginExecutionCommandContext<'a> {
|
||||
let decl = self.engine_state.get_decl(decl_id);
|
||||
|
||||
let stack = &mut self.stack.push_redirection(
|
||||
redirect_stdout.then_some(Redirection::Pipe(OutDest::Capture)),
|
||||
redirect_stderr.then_some(Redirection::Pipe(OutDest::Capture)),
|
||||
redirect_stdout.then_some(Redirection::Pipe(OutDest::PipeSeparate)),
|
||||
redirect_stderr.then_some(Redirection::Pipe(OutDest::PipeSeparate)),
|
||||
);
|
||||
|
||||
let mut call_builder = ir::Call::build(decl_id, call.head);
|
||||
|
Reference in New Issue
Block a user