Skip to content

update ignore to really ignore :) - #18306

Merged
fdncred merged 1 commit into
nushell:mainfrom
fdncred:fdncred/ignore-flags-plan
Jun 2, 2026
Merged

fdncred merged 1 commit into
nushell:mainfrom
fdncred:fdncred/ignore-flags-plan

Conversation

@fdncred

@fdncred fdncred commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR expands ignore so callers can explicitly control which streams (stderr, stdout) are consumed and when errors should be surfaced and update $env.LAST_EXIT_CODE.

User-facing changes (Release notes)

Added stream and error controls to ignore

Update the ignore command with flags to control whether stderr, stdout, or both get consumed and if errors are show which update $env.LAST_EXIT_CODE. This should work on internal and external commands.

Existing behavior is the default when no new flags are provided to avoid breaking changes.

  • Added --stderr (-e) to consume stderr while allowing stdout to pass through.
  • Added --stdout (-o) to consume stdout while allowing stderr output through.
  • Added --show-errors (-x) to show external/internal errors and set $env.LAST_EXIT_CODE (external exit code for external failures, 1 for internal failures).

Additional notes

Closes #17849
Closes #18203

Related #15802
Related #12643

@eaves-dropper

Copy link
Copy Markdown

Hey what about o>, e>, o+e>, out>, err> and out+err> syntaxes? Will that be deprecated?

@fdncred

fdncred commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

Hey what about o>, e>, o+e>, out>, err> and out+err> syntaxes? Will that be deprecated?

no plans for that

@eaves-dropper

Copy link
Copy Markdown

no plans for that

In future?

@fdncred

fdncred commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

I gave up predicting the future long ago.

@fdncred

fdncred commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

Also, all those operators are redirecting, not ignoring, so I'm not sure why they'd be deprecated.

@fdncred
fdncred merged commit 0a127bc into nushell:main Jun 2, 2026
18 checks passed
@fdncred
fdncred deleted the fdncred/ignore-flags-plan branch June 2, 2026 14:54
@github-actions github-actions Bot added this to the v0.114.0 milestone Jun 2, 2026
@eaves-dropper

Copy link
Copy Markdown

Also, all those operators are redirecting, not ignoring, so I'm not sure why they'd be deprecated.

we have tee and save for that use case

@fdncred fdncred added notes:ready Indicates Ready for Release notes notes:additions Noted in "Additions" section labels Jun 8, 2026
fdncred added a commit that referenced this pull request Nov 24, 2026
…`tee` (#19647)

## Description


Since 0.114.0, `try` skips `catch` when it's piped into `ignore`,
`complete`, `save` or `tee` and the error comes from the last command in
its block. `finally` still runs, but it gets the raw error as its input
and parameter, so the first command there that reads either one raises
the error again. The case most likely to bite is a custom command that
ends in a `try`. Call it as `my-command | ignore` and its `catch` never
runs.

#18306 made a command return its error as a value when its stderr goes
to a separate pipe. That lets `ignore --stderr` decide what to do with
the error. All four commands above ask for that separate pipe, and the
last command in a `try` block inherits the redirection of whatever
follows the `try`. So the error turned into a value, passed through
`try` without reaching `catch`, and the next command raised it. Up to
0.117.0, a `;` after the pipeline discarded the error. #19467 stopped
that, so on main the error surfaces.

`try` now raises an error value that reaches the end of its block, or
the end of `catch` before `finally`. The handlers run the same as they
do without the pipe. When only `finally` handles the error, `finally`
gets the error record. Then the error goes on to the next command as a
value, the same as without `finally`, so `ignore --stderr` still
consumes it.


## User-facing changes (Release notes)

- Fixed `try` skipping `catch` when it's piped into `ignore`,
`complete`, `save` or `tee`, including through a custom command that
ends in a `try`. In the same case `finally` now gets the error record
instead of the raw error. This was a regression in 0.114.0.
- `try { ... } catch { 'fallback' } | ignore --stderr` now passes on
`fallback` instead of consuming the error, and `try { exit 3 } | ignore
--stderr` now exits.

## Additional notes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:additions Noted in "Additions" section notes:ready Indicates Ready for Release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: ignore subcommands for stdout/stderr redirection Piping an external command to ignore should not swallow its exit code

2 participants