-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Newline can be added even if --style=plain #1438
Labels
bug
Something isn't working
Comments
Enselic
added a commit
to Enselic/bat
that referenced
this issue
Dec 16, 2020
This fixes sharkdp#1438. Note however, that using a pager such as less will add a newline itself. So to actually not print a newline for such files, you need to either disable paging: bat --style=plain --paging=never no-newline-at-end-of-file.txt or use a "pager" that does not add a newline: bat --style=plain --pager=cat no-newline-at-end-of-file.txt
Thank you for taking the time to write this down in detail! |
Enselic
added a commit
to Enselic/bat
that referenced
this issue
Dec 19, 2020
Since it has a functional role, we can not just replace it, we must keep it around. This also allows us to simplify the code slightly. We must fix this before we fix sharkdp#1438 since otherwise the \n will be missing with --style=plain, since we will stop adding it if it is missing.
Enselic
added a commit
to Enselic/bat
that referenced
this issue
Dec 19, 2020
This fixes sharkdp#1438. Note however, that using a pager such as less will add a newline itself. So to actually not print a newline for such files, you need to either disable paging: bat --style=plain --paging=never no-newline-at-end-of-file.txt or use a "pager" that does not add a newline: bat --style=plain --pager=cat no-newline-at-end-of-file.txt Note that we also update syntax tests file since a bunch of them had missing newlines on the last lines.
Bugfix released in bat v0.18. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In #975 @sharkdp said this:
And I completely agree. The reason the artificial newline was added in the first place was to fix #299, but there should be no risk of regressions since --style=plain excludes any kind of decorations that bug was about.
Note that a pager such as
less
will add an artificial newline too, so one either has to disable paging or use a "pager" that does not add a newline to get the benefit of fixing this bug.Step-by-step:
Expected result:
After 2. and 3. the line shall not contain a newline. I personally use
zsh
to check this since by defaultzsh
will print e.g.%
as the last char if there is a missing newline.Actual result:
A newline is printed with
bat 0.17.1
.(I will soon open a PR with a proposed fix)
The text was updated successfully, but these errors were encountered: