Skip to content

--type should be case-insensitive or at least have an option to #3297

@chillum

Description

@chillum

Please tick this box to confirm you have reviewed the above.

  • I have a different issue.

What version of ripgrep are you using?

ripgrep 15.1.0

How did you install ripgrep?

Homebrew

What operating system are you using ripgrep on?

macOS 15.7.4

Describe your bug.

--type should be case-insensitive or at least have an option to

rg -g '*.htm' will search in 1.HTM when --glob-case-insensitive is provided
rg -t html won't

and it's highly illogical. file extensions originally came from case-insensitive filesystems, so in a random codebase you can see both *.HTM and *.html, they're the same. but somehow the uppercase versions are not searched when using --type and that's terribly wrong.

basically that's the intention of the --type: search in all of them: *.html, *.htm and *.HTM, because the user isn't sure, which one to search. in this logic searching *.htm, but not *.HTM just doesn't make sense!

What are the steps to reproduce the behavior?

I'm using macOS with a default, i.e. case-insensitive filesystem. I do:

$ echo AAA > 1.HTM
$ echo AAA > 2.htm
$ alias rg
rg='rg --smart-case --glob-case-insensitive --no-heading'
$ rg -g '*.htm' AAA
# this matches both files:
2.htm:1:AAA
1.HTM:1:AAA
$ rg -t html AAA
# and this only the lowercase one:
2.htm:1:AAA

What is the actual behavior?

$ rg -t html --debug AAA
rg: DEBUG|rg::flags::parse|crates/core/flags/parse.rs:97: no extra arguments found from configuration file
rg: DEBUG|rg::flags::hiargs|crates/core/flags/hiargs.rs:954: read CWD from environment: /Users/chillum/Repos/ripgrep-test
rg: DEBUG|rg::flags::hiargs|crates/core/flags/hiargs.rs:1092: number of paths given to search: 0
rg: DEBUG|rg::flags::hiargs|crates/core/flags/hiargs.rs:1117: using heuristics to determine whether to read from stdin or search ./ (is_readable_stdin=false, stdin_consumed=false, mode=Search(Standard))
rg: DEBUG|rg::flags::hiargs|crates/core/flags/hiargs.rs:1127: heuristic chose to search ./
rg: DEBUG|rg::flags::hiargs|crates/core/flags/hiargs.rs:1278: found hostname for hyperlink configuration: MacBook-Pro.local
rg: DEBUG|rg::flags::hiargs|crates/core/flags/hiargs.rs:1288: hyperlink format: ""
rg: DEBUG|globset|crates/globset/src/lib.rs:515: built glob set; 0 literals, 0 basenames, 0 extensions, 0 prefixes, 0 suffixes, 3 required extensions, 0 regexes
rg: DEBUG|rg::flags::hiargs|crates/core/flags/hiargs.rs:175: using 12 thread(s)
rg: DEBUG|ignore::gitignore|crates/ignore/src/gitignore.rs:398: opened gitignore file: /Users/chillum/.gitignore
rg: DEBUG|globset|crates/globset/src/lib.rs:515: built glob set; 0 literals, 1 basenames, 0 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
rg: DEBUG|ignore::walk|crates/ignore/src/walk.rs:1942: ignoring ./1.HTM: Ignore(IgnoreMatch(Types(Glob(UnmatchedIgnore))))
rg: DEBUG|ignore::walk|crates/ignore/src/walk.rs:1945: whitelisting ./2.htm: Whitelist(IgnoreMatch(Types(Glob(Matched { def: FileTypeDef { name: "html", globs: ["*.htm", "*.html", "*.ejs"] } }))))
2.htm:1:AAA

What is the expected behavior?

$ echo AAA > 1.HTM
$ echo AAA > 2.htm
$ rg -t html AAA
2.htm:1:AAA
1.HTM:1:AAA

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions