Skip to content

Support multiple -f/--file pattern inputs for ripgrep CLI compatibility #200

Closed

Description

@wuliangtdi

Summary

tgrep accepts only one -f/--file argument. Repeating it causes an argument-parser error, while ripgrep accumulates patterns from all supplied files.

This is a CLI compatibility request. The immediate error makes this easier to detect than the silent pattern loss across search described in a separate report. It is also different from #181, which concerned the contents of one pattern file.

Reproduce

mkdir repro-multiple-pattern-files && cd repro-multiple-pattern-files
mkdir data
printf 'foo\nbar\nbaz\n' > data/input.txt
printf 'foo\n' > p1.txt
printf 'bar\n' > p2.txt

tgrep --no-index -I -f p1.txt -f p2.txt -- data
rg               -I -f p1.txt -f p2.txt -- data
Tool Stdout Exit code
tgrep 1.2.0 Empty 2
rg 15.1.0 foo\nbar\n 0

tgrep stderr:

error: the argument '--file <PATTERN_FILE>' cannot be used multiple times

The rejection occurs during parsing, before any search backend runs. This is not a three-backend reproduction claim.

Environment

  • tgrep 1.2.0, official Windows x86_64 release.
  • Source inspected at release commit 3ba6ee02537281b68ee1366bb40df9f8b7cc54f0.
  • Windows; test harness run with PowerShell 7.
  • ripgrep 15.1.0 (af60c2de9d).
  • Verified on 2026-10-12. The shell examples describe the same fixture bytes and arguments tested on Windows.

Cause

The pattern file field is Option<String> in tgrep-cli/src/main.rs:88, unlike the list-valued -e field.

Possible fix

Accept an ordered collection of pattern-file inputs and combine their patterns with the existing -e inputs. Preserve the already fixed blank-line, empty-file, and whitespace semantics from #181/#187.

A regression could check two files that contribute different patterns, an empty file combined with a nonempty file, and combinations with -e.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions