Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Less -w prints carriage return ^M in blank lines #474

Closed
imbrish opened this issue Jan 30, 2024 · 2 comments
Closed

Less -w prints carriage return ^M in blank lines #474

imbrish opened this issue Jan 30, 2024 · 2 comments

Comments

@imbrish
Copy link

imbrish commented Jan 30, 2024

I have noticed a potential bug in less.

When viewing files with windows line endings (CRLF), less -w shows carriage return ^M in blank lines. Lines which are not empty display correctly, skipping the carriage returns. Without the -w option the ^M are omitted in blank lines too.

The same happens for -W. Adding -r removes the markers but is a rather unacceptable workaround.

$ printf 'A\r\n\r\nB\r\n' | LESS= less -F
A

B

$ printf 'A\r\n\r\nB\r\n' | LESS= less -Fw
A
^M
B

$ printf 'A\r\n\r\nB\r\n' | LESS= less -Fwr
A

B

When text is long enough to scroll down and then back up, the ^M disappear. So, these are only shown in the newly printed lines.

$ for ((i=0; i<40; i++)); do printf 'A\r\n\r\nB\r\n'; done | LESS= less -w
(lines scrolled back to)
A

B
(freshly printed lines)
A
^M
B

Tested with git 2.43.0.windows.1, bash 5.2.21(1), less 643.

@gwsw
Copy link
Owner

gwsw commented Feb 2, 2024

Note: this bug was introduced in 1aad5cb.

@gwsw
Copy link
Owner

gwsw commented Feb 3, 2024

Fixed in 94f1ae3.

@gwsw gwsw closed this as completed Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants