Skip to content

IR: fix incorrect capturing of subexpressions - #13467

Merged
devyn merged 1 commit into
nushell:mainfrom
devyn:ir-fix-capture-of-subexpressions
Jul 28, 2024
Merged

devyn merged 1 commit into
nushell:mainfrom
devyn:ir-fix-capture-of-subexpressions

Conversation

@devyn

@devyn devyn commented Jul 27, 2024

Copy link
Copy Markdown
Contributor

Description

Discovered by @warp on Discord.

The IR compiler was not properly setting redirect modes for subexpressions because FullCellPath was always being compiled with capture-out redirection. This is the correct behavior if there is a tail to the FullCellPath, as we need the value in order to try to extract anything from it (although this is unlikely to work) - however, the parser also generates FullCellPaths with an empty tail quite often, including for bare subexpressions.

Because of this, the following did not behave as expected:

(docker run -it --rm alpine)

Capturing the output meant that docker didn't have direct access to the terminal as a TTY.

As this is a minor bug fix, it should be okay to include in the 0.96.1 patch release.

User-Facing Changes

  • Fixes the bug as described when running with IR evaluation enabled.

Tests + Formatting

I added a test for this, though we're not currently running all tests with IR on the CI, but it should ensure this behaviour is consistent. The equivalent minimum repro I could find was:

(nu --testbin cococo); null

as this should cause the cococo message to appear on stdout, and if Nushell is capturing the output, it would be discarded instead.

@devyn devyn added A:ir-compiler Issues/pull requests related to compiling Nushell parser output to internal representation (IR) notes:fixes Noted in "Bug fixes" section labels Jul 27, 2024
@devyn
devyn merged commit 5f7afaf into nushell:main Jul 28, 2024
@devyn
devyn deleted the ir-fix-capture-of-subexpressions branch July 28, 2024 02:39
@hustcer hustcer added this to the v0.97.0 milestone Jul 28, 2024
@devyn devyn modified the milestones: v0.97.0, 0.96.1 Jul 29, 2024
@sholderbach sholderbach mentioned this pull request Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A:ir-compiler Issues/pull requests related to compiling Nushell parser output to internal representation (IR) notes:fixes Noted in "Bug fixes" section

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants