635 Commits
Author SHA1 Message Date
Keith Hall f0a58595bd Merge branch 'master' into fix-vcredist-link 2026-10-20 22:07:28 +03:00
Navpreet Sidhu 49d9ac1d6e changelog: reference PR #4091 2026-10-20 21:40:03 +05:30
Navpreet Sidhu 54b1f9c6af Fix hang on block comment after an expression in JavaScript 2026-10-20 21:31:39 +05:30
Mikhail Alabugin b841eadf09 Merge upstream into PR branch, resolve conflicts 2026-10-20 13:59:30 +03:00
Keith Hall d3afbaeb06 Merge branch 'master' into patch-1 2026-10-17 14:48:35 +03:00
Keith Hall bc0a67e07c Merge branch 'master' into fix/utf16be-first-line 2026-10-17 14:28:44 +03:00
Claude c2adbf6caa Fix the first line of UTF-16BE input swallowing the second line
In UTF-16BE a newline is 00 0A, so the initial read_until(b'\n') usually
already ends exactly at the end of line 1. The BE branch then always called
read_utf16_line, which read on to the next newline, merging lines 1 and 2.
Only keep reading when the first read did not end on a complete 00 0A.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VVn4SeAXPsUajXT2rtHQfo
2026-10-16 19:50:14 +00:00
injust f48149b119 Add syntax mapping for Podman .quadlets files 2026-10-15 21:52:43 +00:00
ump45nose 8c63b37205 changelog: note StripAnsiMode rustdoc (#4067) 2026-10-15 15:13:56 +08:00
Mathjk 12cbb20de4 changelog: reference PR #4035 so the changelog check passes 2026-10-03 01:03:09 +08:00
Mathjk a9b112b6fe Exit quietly on broken pipe in auxiliary output paths
The main output path has exited with status 0 on EPIPE since #232, but
auxiliary outputs still used println!/print!/io::stdout().flush().unwrap()
and panicked (exit code 101) when the reader of a piped stdout went away
early, e.g. 'bat --completion bash | head -n0'.

Route them through the existing convention instead: write!/writeln! to
io::stdout() and '?' so that Error::Io(BrokenPipe) reaches
default_error_handler, which exits with status 0. This covers
--completion, --config-file, --diagnostic (bugreport's print() becomes
format() + writeln!), --generate-config-file, the 'cache' subcommand
progress messages, the OSC title sequence of --set-terminal-title, and
the 'built without feature' notices.

Closes #4034
2026-10-02 02:23:08 +08:00
mikehasaandClaude Opus 4.8 156ef1d2f4 Track strikethrough (SGR 9) so it is not dropped across highlighted tokens
The `Attributes` ANSI style tracker in `src/vscreen.rs` declares, initializes,
clears (in `sgr_reset`), and re-emits (in `Display`) a `strike` field
documented as `ON: ^[9m / OFF: ^[29m`, but `update_with_sgr()` had no match
arm for SGR 9 (set strikethrough) or 29 (clear strikethrough). As a result
`strike` was only ever cleared, never set.

Because bat re-applies the tracked input ANSI style before each highlighted
text run (nu_ansi_term appends a full reset after every token), attributes
that are tracked — bold, dim, italic, underline — survive across tokens,
while strikethrough was silently dropped after the first token. This path is
active by default (`--strip-ansi`/`--sanitize` default to `never`).

Add the missing `9` and `29` arms, mirroring the sibling underline (4/24) and
italic (3/23) arms, so strikethrough is tracked and re-emitted like every
other supported attribute.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-22 05:15:31 -07:00
Mikhail Alabugin eca6c5b688 Merge branch 'master' into fix-vcredist-link 2026-09-05 16:01:25 +03:00
LOG cf72a432ac Allow boolean flags to be repeated
bat prepends the arguments from its config file to the command line, so a
user who has `--show-all` in their config and also types `-A` passes the
flag twice, and clap rejects that with "the argument '--show-all' cannot be
used multiple times" and exit code 2. The file is never displayed.

`--plain`, `--number`, `--number-nonblank`, `--force-colorization` and
`--no-paging` already avoid this by overriding themselves. The same is now
done for the eight remaining flags that affect how a file is displayed:
--show-all, --diff, --chop-long-lines, --squeeze-blank, --unbuffered,
--quiet-empty, --no-custom-assets and --set-terminal-title.

Repeating a flag produces byte-identical output to giving it once, and
--show-all still conflicts with --language as before.
2026-09-04 18:01:33 +08:00
cuishuang b784eaf0ae Use parsed CLI arguments to detect number flags
Signed-off-by: cuishuang <imcusg@gmail.com>
2026-09-04 11:00:36 +08:00
Keith Hall 5fee86b97b Merge branch 'master' into fix-binary-detection-across-lines-3554 2026-09-03 21:54:06 +03:00
cuishuang 2ed7adc49f Merge upstream master to resolve PR conflicts 2026-09-03 20:07:25 +08:00
Mikhail Alabugin ea3909bbdf Add changelog entry 2026-09-02 11:10:47 +03:00
Abhishek Murthy 7892a8754b chore: add pull request number to changelog 2026-08-31 18:06:25 +00:00
Abhishek Murthy 400c5dc6f1 fix: avoid parsing syntax fixture as Cargo manifest 2026-08-31 17:47:24 +00:00
cuishuang 1cedc1b4c3 fix: use last occurrence in combined short flags
Signed-off-by: cuishuang <imcusg@gmail.com>
2026-08-28 22:23:39 +08:00
MeGaurav4 de2e651bf5 Merge remote-tracking branch 'origin/master' into pr-3857 2026-08-11 11:48:10 +05:30
MeGaurav4 061fb216cb feat: implement -b / --number-nonblank for cat -b compatibility
Adds a `-b` / `--number-nonblank` flag that numbers only non-blank
lines.  Blank lines (those containing only the line terminator) are
printed without a number and don't advance the counter, matching
`cat -b` behaviour.

- `-b` implies `--style=numbers` (same as `-n`), but only counts
  non-blank lines
- `-b` takes precedence over `-n`: both `-bn` and `-nb` behave like `-b`
- `-bp` disables numbering (plain mode wins)
- Works with files, stdin, and piped output (like `-n`)

Closes #3856.
2026-08-11 11:48:10 +05:30
Matei6942 bb492fff47 Add changelog entry for #3877 2026-08-02 11:53:54 +03:00
Matei6942 531d54b110 docs: add changelog entry for #3876 2026-08-02 10:52:39 +03:00
lenamonj df38225653 Add CHANGELOG entry for #3862 2026-07-29 17:02:33 -04:00
Keith Hall 3a7a750969 Merge branch 'master' into fix-list-languages-paging-never 2026-07-29 21:25:10 +03:00
Tyce Herrman d449ce5b7e chore(deps): resolve current cargo audit failures 2026-07-29 12:10:05 -04:00
cyphercodes 218afc30ac Respect paging mode for list languages 2026-07-04 06:31:26 +03:00
curious-rabbit d72163160e add sanitize option 2026-07-01 07:09:49 +02:00
Adrian Rivera c75cc01eef Fix --ignored-suffix to fall back to first-line detection
When an ignored suffix is also a registered extension (e.g. `.txt` maps to
"Plain Text"), `get_syntax_for_file_extension` matched the raw extension
before attempting the suffix strip. As a result `--ignored-suffix .txt` had
no effect on such files and first-line/shebang detection was never reached,
so a shell script saved as `*.txt` stayed unhighlighted.

Strip ignored suffixes first and detect on the remainder; only fall back to
the raw extension when no ignored suffix applies. When a suffix is stripped
but the remainder has no syntax, return `None` so the caller can use
first-line detection. Default behavior (no `--ignored-suffix`) is unchanged.

See #2745.
2026-06-30 12:20:14 -07:00
Keith Hall 20a818fe14 Merge branch 'master' into patch-1 2026-06-27 21:58:52 +03:00
injust 088f1e4253 Add changelog entry 2026-06-27 12:50:29 -04:00
Keith Hall a4609d1778 Merge branch 'master' into fix/list-languages-narrow-width-underflow 2026-06-27 06:03:16 +03:00
blinxen e2568c52cd Use correct PR number 2026-06-26 20:27:49 +02:00
blinxen c5e6f6aae3 Replace libgit2 with gitoxide 2026-06-26 20:27:49 +02:00
greymoth 8f93137246 doc(changelog): add #3812 bugfix entry 2026-06-26 22:13:51 +09:00
Dhruv Bhanushali d117bf2320 Summarise the change in the CHANGELOG.md file 2026-06-23 08:08:14 +04:00
Cosmic Horror 6b8887133d feat: add syntax highlighting for Caddyfile 2026-06-17 04:44:53 -06:00
weili d28aa4a8b4 Fix capacity-overflow panic in print_snip at --terminal-width 1
`InteractivePrinter::print_snip` computes the snip separator width as
`term_width - panel_count - snip_left_count - title_count`. At `--terminal-width 1`
the panel is disabled and `title_count == 2`, so the subtraction underflows
`usize` (release has no overflow-checks, so it wraps to ~usize::MAX); `str::repeat`
then aborts with "capacity overflow" whenever a snip separator is emitted (two or
more disjoint line ranges, or a diff gap) — which the default style does.

Use `saturating_sub` for the repeat counts so they clamp to 0 instead of
underflowing. Added an integration test.
2026-06-16 07:06:29 +00:00
Matt Van Horn 66e336bcfb fix(completions): force --no-paging on bat invocations in completion scripts (#3760)
Every shell completion script (bash, zsh, fish, PowerShell) shells out
to bat to enumerate languages/themes for tab completion candidates. If
the user has wired bat into LESSOPEN (e.g. LESSOPEN='|-bat -f -pp %s'),
bat's normal pager auto-detection can engage when stdout looks like a
terminal at completion time and reflect ANSI escape sequences back into
the candidate list. The result is the issue's reproducer: tab completion
expands 'Per' to '\033[38;2;248;248;242mPerl' instead of 'Perl'.

The list-languages/list-themes calls are always meant to be machine-
readable, so they should never page. Pass --no-paging explicitly to
every bat invocation inside the four completion files. The flag is the
public alias for --paging=never (already documented in bat --help) and
is the same form completion scripts elsewhere in the codebase use.

Touches the four completion files only; no production code changes.
2026-05-19 04:19:31 -07:00
Keith Hall f9fa590c3d Merge branch 'master' into patch-1 2026-05-18 20:11:48 +03:00
Justin Su 0ef0342ff2 Add changelog entry 2026-05-18 03:33:50 -04:00
Justin Su 43c4957e18 Add changelog entry 2026-05-18 03:08:39 -04:00
truffle 98df25434e fix: reference PR number in changelog entry 2026-05-10 09:20:40 +00:00
truffle 5f952066fb fix: only offer language names in zsh tab completion for -l
The previous awk script in `bat.zsh.in` split each line of
`bat --list-languages` on `:` or `,` and emitted every field as a
completion candidate, including the second column. That column lists
file matchers, which can be plain extensions (`rs`), globs (`*.rs`),
absolute paths (`/etc/profile`), or filenames (`Containerfile`). None
of those parse as `-l` arguments, so completing them produces
`unknown syntax` errors.

Switch to splitting on `:` only and emit the language name as the
completion value with the file-matcher list as its description, which
matches the bash completion's behavior.

Closes #3735.
2026-05-10 09:19:54 +00:00
curious-rabbit c437ad4d27 fix command injection in LESS template 2026-05-06 00:46:35 +02:00
Keith Hall f7b84a3b41 Merge branch 'master' into makefile-syntax-for-justfiles 2026-05-02 13:56:45 +03:00
Keith Hall 12ee94f530 Merge branch 'master' into list-themes-term-probe-fix 2026-04-30 14:13:47 +03:00
Keith Hall 54bfc33248 Merge branch 'master' into fix/lessclose-nonzero-warning 2026-04-30 08:10:40 +03:00