nushell / nushell/nushell

`ansi` command should not output ANSI color codes when `use_ansi_coloring` is disabled in config

Open
#14,194 16 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status:needs-triage
Dominant language
Rust
Stars
40.5k
Forks
2.3k
Avg merge
1d 19h
Merged PRs (30d)
85

Description

Describe the bug

This is the root cause of #14043.

In (unrelated to 14043) digging around in the ansi command, it comes to mind that the reason why user-land ANSI was still coloring output in #14043 is that the ansi command itself still outputs color codes, even when use_ansi_coloring is false.

This shouldn't happen.

The ansi command actually checks the use_ansi_coloring option, but only to determine if color previews should be shown with ansi --list/-l. It should also check before outputting a color (or attribute) code.

How to reproduce

Note: to reproduce correctly, each line of the following must be executed separately; otherwise the environment won't be re-read before the command is executed ...

$env.use_ansi_coloring = false
$"(ansi red)This shouldn't be Red, but it is(ansi reset)"
Expected behavior

I expect the ansi command to disregard color and attribute codes when use_ansi_coloring is false. ANSI codes related to cursor positioning, clearing the screen, and others should still be output.

Configuration
key value
version 0.98.1
major 0
minor 98
patch 1
branch virtual-mods
commit_hash 1dc58b84a85a7d7e8fa4a9fec866582eddcfc036
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.79.0 (129f3b996 2024-06-10)
rust_channel 1.79.0-x86_64-unknown-linux-gnu
cargo_version cargo 1.79.0 (ffa9cf99a 2024-06-03)
build_time 2024-10-09 13:39:29 -04:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash
installed_plugins

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the ansi command implementation and its existing use_ansi_coloring check, which currently only affects ansi --list/-l. Verify the reproduction with $env.use_ansi_coloring = false; done means color and attribute codes are suppressed while cursor-positioning and screen-clearing codes still output.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.