mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 03:57:44 +00:00
dircolors: fix empty COLORTERM matching with ?* pattern
should fix tests/misc/dircolors
This commit is contained in:
parent
1ffb6fd5b1
commit
1db2e2356a
2 changed files with 25 additions and 1 deletions
|
@ -374,6 +374,7 @@ where
|
|||
|
||||
let term = env::var("TERM").unwrap_or_else(|_| "none".to_owned());
|
||||
let term = term.as_str();
|
||||
let colorterm = env::var("COLORTERM").unwrap_or_default();
|
||||
|
||||
let mut state = ParseState::Global;
|
||||
|
||||
|
@ -396,8 +397,20 @@ where
|
|||
));
|
||||
}
|
||||
let lower = key.to_lowercase();
|
||||
|
||||
if lower == "term" || lower == "colorterm" {
|
||||
if term.fnmatch(val) {
|
||||
let should_match = if lower == "colorterm" {
|
||||
// For COLORTERM ?*, only match if COLORTERM is non-empty
|
||||
if val == "?*" {
|
||||
!colorterm.is_empty()
|
||||
} else {
|
||||
colorterm.fnmatch(val)
|
||||
}
|
||||
} else {
|
||||
term.fnmatch(val)
|
||||
};
|
||||
|
||||
if should_match {
|
||||
state = ParseState::Matched;
|
||||
} else if state != ParseState::Matched {
|
||||
state = ParseState::Pass;
|
||||
|
|
|
@ -253,3 +253,14 @@ fn test_repeated() {
|
|||
new_ucmd!().arg(arg).arg(arg).succeeds().no_stderr();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_colorterm_empty_with_wildcard() {
|
||||
new_ucmd!()
|
||||
.env("COLORTERM", "")
|
||||
.pipe_in("COLORTERM ?*\nowt 40;33\n")
|
||||
.args(&["-b", "-"])
|
||||
.succeeds()
|
||||
.stdout_is("LS_COLORS='';\nexport LS_COLORS\n")
|
||||
.no_stderr();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue