gwsw / less

Less - text pager
http://greenwoodsoftware.com/less
Other
560 stars 88 forks source link

Output differs (and is wrong) from cat on colored file from stark/Color-Scripts #41

Closed ericonr closed 4 years ago

ericonr commented 4 years ago

less version: 551 (PCRE regular expressions)

I was taking a look at the colored terminal scripts from stark/Color-Scripts, and one of them was, instead of a script, a text file that had to be printed to STDOUT to be visualized. It was the crowns file. When shown using

less --RAW-CONTROL-CHARS crowns

it shows a different (wrong) result than when simply printing it to the terminal (using cat).

The output from both commands (cat and less through bat) can be seen in this asciinema.

I have verified the same behavior in both Konsole and Alacritty, and have guaranteed that my terminal was wide enough for the file to be printed on it.

I first realized this problem in this issue with bat.

gwsw commented 4 years ago

The problem with the crowns file is it contains cursor-movement commands. There are numerous instances in the file of "ESC [ nn C" sequences to move the cursor right. This will behave differently on different terminals. It might work if you use -r but that's not recommended due to the potential for display problems if the embedded cursor movements interfere with less's management of the screen.

ericonr commented 4 years ago

Yeah, it did work with -r. I also added -f so it didn't show the prompt asking if I wanted to read a binary file. Thanks!

That said, should I close the issue?