Skip to content

ls: match glob patterns in the TERM list - #15728

Open
fixfon wants to merge 2 commits into
uutils:mainfrom
fixfon:fix/9098-ls-color-term-glob
Open

fixfon wants to merge 2 commits into
uutils:mainfrom
fixfon:fix/9098-ls-color-term-glob

Conversation

@fixfon

@fixfon fixfon commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Closes #9098

TERM=konsole-256color ls --color=always printed no color. is_color_compatible_term matched the entries of uucore::colors::TERMS either exactly or as a prefix when they end in *, but a few entries are real glob patterns: *color*, *direct* and con[0-9]*x[0-9]* were read as literal prefixes and never matched anything. The closure now matches every entry with parse_glob::from_str, the same way ls already handles --ignore and --hide, and dircolors matches this list. linux-256color and vte-256color were affected the same way and now get color. dumb is in none of the patterns, so it still gets none.

I added test_term_glob_patterns to tests/by-util/test_ls.rs. It checks konsole-256color, linux-256color, konsole-direct and con80x25 get color, that xterm-256color and konsole still do, and that dumb does not. It fails without the fix on TERM=konsole-256color and test_ls passes with it (186 passed, 1 ignored). cargo fmt and clippy -p uu_ls --all-targets -D warnings are clean. Tested on macOS only.

The entries in the TERMS list are glob patterns, but ls only honored an exact name or a trailing *. Patterns such as *color* and con[0-9]*x[0-9]* never matched, so TERM=konsole-256color got no color.

Fixes uutils#9098
…m-glob

# Conflicts:
#	tests/by-util/test_ls.rs

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ls --color doesn't work when TERM is konsole-256color

1 participant