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
admirabilis opened this issue Nov 28, 2018 · 3 comments
Closed

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

admirabilis opened this issue Nov 28, 2018 · 3 comments

Comments

@admirabilis
Copy link

admirabilis 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).

@admirabilis
Copy link
Author

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
Copy link
Owner

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
───────┴────────────────────────────────────────────────────────────

@admirabilis
Copy link
Author

That is very useful indeed, thanks!

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