fix: NO_COLOR does not win over CLICOLOR_FORCE under --color=auto

Open Beginner friendly
#110 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go, shell
Domain
cli

Research direction

Start in internal/cli/colorflag.go: the stated precedence is at lines 101-103, the NO_COLOR rewrite in rewriteEnviron at 115-135, and the handling around 155-168. The fix is to drop CLICOLOR_FORCE from the environment when NO_COLOR is non-empty under --color=auto, before colorprofile reads it. Reproduce with NO_COLOR=1 CLICOLOR_FORCE=1 codegraph version | cat -v, then add a test for that input asserting zero ESC bytes, which should fail on the current code.

Written by the indexing model from the issue text.

Description

bug priority:low
What happens
$ NO_COLOR=1 CLICOLOR_FORCE=1 codegraph version | cat -v
^[[1;38;2;95;215;255mcodegraph dev^[[m ^[[2;38;2;147;161;161m(commit unknown, built unknown)^[[m ...

Under --color=auto, rewriteEnviron rewrites NO_COLOR to NO_COLOR=1 but passes CLICOLOR_FORCE through unchanged, and colorprofile lets CLICOLOR_FORCE win.

What you expected instead

No escape bytes. The code's stated order is NO_COLOR > CLICOLOR_FORCE > CLICOLOR=0 > TTY.

Steps to reproduce

Run the command above with any build of main.

Version

main at d384473e (built locally, codegraph dev)

Platform

macOS 27 arm64

How did you install it?

Built from source

Evidence
  • internal/cli/colorflag.go:101-103 (stated order), :115-135 (NO_COLOR rewritten, CLICOLOR_FORCE kept), :155-168
Acceptance criteria
  • With a non-empty NO_COLOR, --color=auto drops CLICOLOR_FORCE before colorprofile sees it.
  • A test covering NO_COLOR=1 CLICOLOR_FORCE=1 asserts zero ESC bytes, and fails on the current code.

Source (GSD planning files, archived at d384473e): .planning/milestones/v0.14.0-MILESTONE-AUDIT.md (T-04-30)


🤖 Generated with Claude Code

https://claude.ai/code/session_01UNqdnC3q6U362BvyfxuKCF

Dominant language
Go
Stars
0
Forks
0
Avg merge
5h 16m
Merged PRs (30d)
107

Getting set up

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.

More from seanb4t/codegraph-go

All issues in seanb4t/codegraph-go

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.