Skip to content

Incorrect syntax highlighting of Bash here-strings #3648

@schuelermine

Description

@schuelermine

What steps will reproduce the bug?

The following Bash program:

cat <<A; cat <<B; cat <<C
String A
A
String B
B
String C
C

What happens?

is incorrectly highlighted as

Image

What did you expect to happen instead?

because Bat thinks the here-strings are ordered C, B, A, but they are in fact ordered A, B, C

How did you install bat?

nixpkgs cda48547b432e8d3b18b4180ba07473762ec8558


bat version and environment

Software version

bat 0.26.1

Operating system

  • OS: Linux (NixOS 26.05)
  • Kernel: 6.19.8

Command-line

/home/anselmschueler/.nix-profile/bin/bat --language bash --diagnostic 

Environment variables

BAT_CACHE_PATH=<not set>
BAT_CONFIG_PATH=<not set>
BAT_OPTS=<not set>
BAT_PAGER=<not set>
BAT_PAGING=<not set>
BAT_STYLE=<not set>
BAT_TABS=<not set>
BAT_THEME=<not set>
COLORTERM=truecolor
LANG=en_GB.UTF-8
LC_ALL=<not set>
LESS=<not set>
MANPAGER=<not set>
NO_COLOR=<not set>
PAGER=less
SHELL=/run/current-system/sw/bin/fish
TERM=xterm-256color
XDG_CACHE_HOME=<not set>
XDG_CONFIG_HOME=<not set>

System Config file

Could not read contents of '/etc/bat/config': No such file or directory (os error 2).

Config file

--style=numbers,changes,rule,snip

Custom assets metadata

bat_version: 0.26.1
creation_time:
  secs_since_epoch: 1774054094
  nanos_since_epoch: 983655630

Custom assets

  • metadata.yaml, 97 bytes
  • syntaxes.bin, 1012454 bytes
  • themes.bin, 58318 bytes

Compile time information

  • Profile: release
  • Target triple: x86_64-unknown-linux-gnu
  • Family: unix
  • OS: linux
  • Architecture: x86_64
  • Pointer width: 64
  • Endian: little
  • CPU features: fxsr,sse,sse2
  • Host: x86_64-unknown-linux-gnu

Less version

> less --version 
less 691 (PCRE2 regular expressions)
Copyright (C) 1984-2025  Mark Nudelman

less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Home page: https://greenwoodsoftware.com/less

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsyntect-features-requiredBlocked by lack of support in syntectupstream-errorA bug in an upstream component

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions