dircolors: honor TERM/COLORTERM for the built-in database - #14408
Open
Socialpranker wants to merge 1 commit into
Open
dircolors: honor TERM/COLORTERM for the built-in database#14408Socialpranker wants to merge 1 commit into
Socialpranker wants to merge 1 commit into
Conversation
|
GNU testsuite comparison: |
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.
Without a config file,
dircolorsemitted the whole built-in database nomatter what terminal it was running under:
Same for
TERM=dumb,TERM=some-unknown-term,-cand--print-ls-colors.The config-file path already honors
TERM/COLORTERMlines; only thebuilt-in path did not.
The fix
The built-in database is guarded by
COLORTERM ?*plus oneTERMentry perknown terminal — the entries
--print-databaseprints.generate_ls_colorsnow applies that same guard before emitting anything, using the
TERMSlistand the existing
fnmatchhelper, and returns an emptyLS_COLORSwhennothing matches.
-pstill dumps the database unfiltered, as before.Testing
tests/by-util/test_dircolors.rscovering unknownTERM,unset
TERM,--print-ls-colors, a knownTERM,COLORTERMwith anunknown
TERM, and-pstaying unfiltered. Mutation-checked: neuteringthe guard fails three of them.
test_ls_colorsgained.env("TERM", "screen"), matching its-b/-csiblings; it previously relied on the unfiltered output.
cargo test --features dircolors --test tests test_dircolors: 24 passed,0 failed.
cargo clippy -p uu_dircolors --all-targets -- -D warningsandcargo fmt --check: clean.TERM/COLORTERMcombinations plus 5 config-file cases: 8 filteringmismatches before, 0 after, no case regressed.
Disclosure
Prepared with AI assistance (Claude Opus 5, via Claude Code), per the AI
policy in CONTRIBUTING.md. GNU behavior above came from running the
installed binary, not from reading GPL source. All testing was run locally.