When using bat on YAML files that include comments which start at the beginning of a line, that is, the first character of the line is a #, bat will hang indefinitely, and never finish displaying the file.
cat:$ cat works.yml
test: value
still: okay
# comment with hash character at beginning of line, but with a space first
will: reach here
bat:$ bat works.yml
ββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β File: works.yml
ββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
1 β test: value
2 β
3 β still: okay
4 β
5 β # comment with hash character at beginning of line, but with a space first
6 β
7 β will: reach here
ββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
$
cat:$ cat broken.yml
test: value
still: okay
# comment with hash character at beginning of line
will: not reach here
bat:$ bat broken.yml
ββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β File: broken.yml
ββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
1 β test: value
2 β
3 β still: okay
4 β
From this point on, it will linger forever and never finish. Even the comment line isn't shown. Something seems to be wrong with the syntax parsing in this case.
It _does_ work with the -A flag enabled:
$ bat -A broken.yml
ββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β File: broken.yml
ββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
1 β test:β’valueβ
2 β β
3 β still:β’okayβ
4 β β
5 β #β’commentβ’withβ’hashβ’characterβ’atβ’beginningβ’ofβ’lineβ
6 β β
7 β will:β’notβ’reachβ’hereβ
ββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
$
It is consistently repeatable. Different values of --style do not change the outcome, it hangs every time.
$ bat --version
bat 0.9.0
bat installed via Homebrew on OS X Mojave.
Darwin Kernel Version 18.2.0: Fri Oct 5 19:41:49 PDT 2018; root:xnu-4903.221.2~2/RELEASE_X86_64 x86_64
there was a similar issue which was fixed upstream: https://github.com/trishume/syntect/issues/219
I wonder what is happening in this case
@tomgoren Thank you for the detailed bug report!
I can not reproduce this.
This looks very much like the bug that I have reported upstream, as @keith-hall mentioned. It only appeared if a syntax set was dumped to disk and reloaded again.
Did you use bat cache --init in the past (with an older version of bat)? Can you try to run
bat cache --clear
to see if the error goes away?
If that is the case, you should be able to run bat cache --init again without any issues.
Holy moly @sharkdp - that fixed it! Thanks. Sorry for any confusion.