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

Should not automatically add \n when using --plain #434

Closed
teresaejunior opened this issue Nov 28, 2018 · 3 comments
Closed

Should not automatically add \n when using --plain #434

teresaejunior opened this issue Nov 28, 2018 · 3 comments

Comments

@teresaejunior
Copy link

@teresaejunior teresaejunior commented Nov 28, 2018

#300 ads a newline character to the output to avoid issues with the grid, which is understandable. But when using bat --plain, I would expect it to behave like cat, that is, if there is no newline at the end, I need to know it.

If the file is broken, it shouldn't be bat's job to fix it (some shells will deal with the annoyances of the output beautifully, like fish, which puts a ⏎ at the end of the output to show there is no newline, instead of leaving a broken prompt).

@teresaejunior

This comment has been minimized.

Copy link
Author

@teresaejunior teresaejunior commented Nov 28, 2018

I have compiled a version of bat removing the code introduced in #300, and it doesn't seem to make any difference. Also, there is the fact that less also guarantees a newline at the end of files, so this is not much worth pursuing.

@sharkdp

This comment has been minimized.

Copy link
Owner

@sharkdp sharkdp commented Dec 2, 2018

Thank you for the feedback. I do agree with your opinions and conclusions.

As a side-comment: note that you can use bat --show-all to check if there is a line-feed at the end of the file.

For example, compare:

▶ echo "test" | bat -A   
───────┬────────────────────────────────────────────────────────────
       │ STDIN
───────┼────────────────────────────────────────────────────────────
   1   │ test␊
───────┴────────────────────────────────────────────────────────────

~                                                                  
▶ echo -n "test" | bat -A
───────┬────────────────────────────────────────────────────────────
       │ STDIN
───────┼────────────────────────────────────────────────────────────
   1   │ test
───────┴────────────────────────────────────────────────────────────

@teresaejunior

This comment has been minimized.

Copy link
Author

@teresaejunior teresaejunior commented Dec 3, 2018

That is very useful indeed, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.