Skip to content

fix: validate configured language in plain piped output - #4001

Open
ryanchou1994 wants to merge 2 commits into
sharkdp:masterfrom
ryanchou1994:fix/validate-piped-language
Open

fix: validate configured language in plain piped output#4001
ryanchou1994 wants to merge 2 commits into
sharkdp:masterfrom
ryanchou1994:fix/validate-piped-language

Conversation

@ryanchou1994

Copy link
Copy Markdown

When bat -l InvalidSyntax writes to a pipe, it currently copies the input and exits successfully. Forcing colored output reports the unknown language instead. Validate a configured language before creating the simple printer so plain piped output reports the same error, including for empty input. Valid languages still pass the input through unchanged, and output without a configured language keeps lazy syntax loading.

The regression tests cover both error cases, language names and extension tokens, unchanged CRLF/tab output, and a damaged syntax cache that plain output does not need to read. The existing attached-option-value test now uses the valid crontab language, retaining its check that b and n inside a language value do not enable line numbering.

Validation on Linux with Rust 1.98.0:

  • The two error regressions fail before the fix and pass after it.
  • cargo test --locked --offline -- --test-threads=2: 455 passed, 5 ignored.
  • cargo fmt -- --check.
  • cargo clippy --locked --offline --all-targets --all-features -- -D warnings.

Refs #2372.

Copilot AI lite review requested due to automatic review settings September 8, 2026 17:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants