Repository navigation
Fix is-terminal OS detection and add is-redirected for pipeline destinations - #18661
Merged
Merged
Conversation
Merged
fdncred
pushed a commit
that referenced
this pull request
Jul 18, 2026
<!-- Thanks for contributing to Nushell! Before submitting, please read the contributing guide: https://github.com/nushell/nushell/blob/main/CONTRIBUTING.md This template helps reviewers understand your changes and allows us to generate high-quality release notes. --> ## Description <!-- Explain what this PR does and why. This section is intentionally flexible: - Describe the problem - Explain your approach - Include technical details if relevant Good examples: - "In this PR, I fixed..." - "In this PR, I added support for..." - "This change improves X by..." Write as much or as little as needed for reviewers to understand your changes. --> This PR updates some tests of #18661 to make them more compact and use more of our testing infra. ## User-facing changes (Release notes) <!-- This section is used (mostly as-is) for https://www.nushell.sh/blog/ Describe how Nushell behavior changes from a user's perspective. Do NOT describe internal Rust changes here. Write in a release note style, for example: - "Added support for..." - "Fixed an issue where..." - "Nushell now supports..." - "Improved performance of..." If your changes do NOT affect users (internal refactors, cleanup, etc.), just write: - "n/a" - "nan" - or similar This tells us the change should not appear in the changelog. Tips: - Focus on observable behavior - Include examples if helpful - Keep it concise You can: - Write a short paragraph (will appear as a bullet point), OR - Use headings (###) if your change needs more structure Avoid writing things like: - "In this PR, I refactored..." - "This updates internal code..." You may leave this blank until the PR is ready. --> n/a
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR updates/reverts the
is-terminalcommand to it's original state so it can detect ttys and we add a new commandis-redirectedto determine redirection. We conflated these two commands and it was confusing.is-terminal(restored)--stdin/--stdout/--stderr.--stdout(kept from Allowis-terminalto detect redirection #18443).if (…),let, and mid-block again.is-redirected.is-redirected(new)truewhen the current custom command’s return value is not going to the interactive display path.if (is-redirected)).User-facing changes (Release notes)
Fixed
is-terminalso it again reports whether process stdin/stdout/stderr is a real terminal (like bashtest -t), including insideif (is-terminal). This restores correct detection for scripts such as./script.nu | cat.Added
is-redirectedfor custom commands to detect whether their return value is piped, collected (let), written to a file, or discarded—versus printed for display. Unlike checking process stdout, this is stable for the whole command body and works insideif (is-redirected).Example for pretty-vs-data commands:
Scripts that only care about process stdout still use:
is-terminalwith no flags still defaults to checking stdout.A few other examples of how
is-redirectedis only designed to work on nushell destinations. These are all redirections with nushell destinations akais-redirected = true.Additional notes
closes #15368