Skip to content

Erratic output when OSC8 sequences are present #2541

@rockorager

Description

@rockorager

Hello -

When bat displays something that already includes an OSC8 sequence, it has erratic output, dependent on the terminal-width. Seemingly, OSC8 ids and urls are included in line-wrapping which leads to strange output depending on where the line is cut.

What steps will reproduce the bug?

Works as expected:

echo '\e]8;;http://example.com\e\\This is a link\e]8;;\e\\\n' | bat --terminal-width=64

Includes escape characters in output:

echo '\e]8;;http://example.com\e\\This is a link\e]8;;\e\\\n' | bat --terminal-width=48

No escape characters, but incorrect wrapping:

echo '\e]8;;http://example.com\e\\This is a link\e]8;;\e\\\n' | bat --terminal-width=40

What happens?

If you keep changing the terminal width, strange things keep happening.

What did you expect to happen instead?

The output should be the same in all above scenarios, as long as terminal-width is greater than the length of the printable section of an OSC8 sequence ("This is a link") in this case.

How did you install bat?

sudo pacman -S bat

bat version and environment

Software version

bat 0.23.0 (871abd2)

Operating system

Linux 6.2.10-arch1-1

Command-line

bat --terminal-width=24 --diagnostic 

Environment variables

SHELL=/usr/bin/zsh
PAGER=<not set>
LESS=<not set>
LANG=en_US.UTF-8
LC_ALL=<not set>
BAT_PAGER=<not set>
BAT_CACHE_PATH=<not set>
BAT_CONFIG_PATH=<not set>
BAT_OPTS=<not set>
BAT_STYLE=<not set>
BAT_TABS=<not set>
BAT_THEME=<not set>
XDG_CONFIG_HOME=<not set>
XDG_CACHE_HOME=<not set>
COLORTERM=truecolor
NO_COLOR=<not set>
MANPAGER=<not set>

System Config file

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

Config file

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

Custom assets metadata

Could not read contents of '/home/tim/.cache/bat/metadata.yaml': No such file or directory (os error 2).

Custom assets

'/home/tim/.cache/bat' not found

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 608 (PCRE2 regular expressions)
Copyright (C) 1984-2022  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 working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions