-
-
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
Request: Flag to report missing newline before EOF #975
Comments
I like this idea, but I'm not that much of a fan of using an emoji inside the output. There's still a few environments that can't render them, sadly. We would also need to consider what it looks like with the grid mode. Maybe something like this?
|
Sure, that was just what came to mind as an example. We're down to a matter of taste, but I'd prefer |
Perhaps As for the command line options, after a little thought, maybe it should be something similar to how we handle style components:
That could be added to the config file, and it would be more flexible for if we ever added more warning types (e.g. mixed indentation maybe?). |
Just FYI, |
Thank you for reporting this. The fact that ❯ printf "hello" | bat -p | hexdump -C
00000000 68 65 6c 6c 6f |hello|
00000005
# force "interactive" mode:
❯ printf "hello" | bat -p --decorations=always | hexdump -C
00000000 68 65 6c 6c 6f 0a |hello.|
00000006
I'm not sure if I'm a big fan of this feature. Yes, the perfectionist in me also doesn't like files without newlines at the end, but do we really need Note that we already have
|
I've run into some "fun" bugs caused by (sublime text and other) editors not ending the last line with a newline (as required by POSIX). For example, |
"Normal" people don't need this, but occasionally it may turn out useful. Normally I don't want this warning, but sometimes I might. Having that warning controlled by an explicit flag seems a good idea. |
@obfusk Thank you for the feedback! Indeed:
I didn't know that. I also didn't know that POSIX requires an EOL at the EOF. So maybe we could choose something less intrusive (instead of printing an additional line if there is no EOL)? Maybe we could print a red |
POSIX defines a line as a |
I agree that having a big warning is probably overkill. But I would very much recommend having some kind of warning by default. And an option to disable it for those who know what they are doing. |
I'm not sure who's going to end up implementing this, but I would recommend that it's done similarly to the style components. If we ever have another warning to add, I think it would be better to have a single flag for them all (e.g. |
Sorry that I didn't mention the POSIX definition of a line in my initial post, but that's exactly where my troubles and this request is rooted. Thanks to @obfusk for bringing in the convincing arguments. |
Note that Whilst FYI: |
If you use a warning sign instead of a message, please make it easy for users to find out what it means. |
Hi!
I am a
zsh
user and got used to my shell "reporting" when there is no newline at the end of the output (a "partial" line):(Note the
%
.)However, that doesn't work with
bat
.I'd like to go one step further, and request a flag on
bat
that will print an explicit warning in case the input does not end in a newline character. Such as:Edit after comment:
I agree that it might be bad to use an emoji, so I propose:
The text was updated successfully, but these errors were encountered: