Most active commenters
  • perching_aix(4)

←back to thread

422 points km | 15 comments | | HN request time: 1.537s | source | bottom
Show context
perching_aix ◴[] No.41831129[source]
Well, at least the title is honest. Straight up asking people to break standards out of sheer conviction is a new one for me personally, but it's definitely one of the attitudes of all time, so maybe it's just me being green.

Can we ask for the typical *nix text editors to disobey the POSIX standard of a text file next, so that I don't need to use hex editing to get trailing newlines off the end of files?

replies(4): >>41831233 #>>41831275 #>>41831592 #>>41833146 #
1. 201984 ◴[] No.41831233[source]
What's wrong with trailing newlines?
replies(2): >>41831241 #>>41831375 #
2. perching_aix ◴[] No.41831241[source]
Other than select software being pissy about it, not much. Just like how there's nothing wrong with CRLF, except for select software being pissy about that too.
replies(2): >>41832054 #>>41832819 #
3. norir ◴[] No.41831375[source]
It makes writing parsers more complicated in certain cases because you can't tell without lookahead if a newline character should be treated as a newline or an eof.
replies(1): >>41831718 #
4. viraptor ◴[] No.41831718[source]
What? Which crazy non-binary format makes a distinction between CRLF(EOF) and just (EOF)? Apart from a plain text file, that is.
replies(1): >>41832157 #
5. bmitc ◴[] No.41832054[source]
Yep. Select software being Unix command line tools.
6. nunobrito ◴[] No.41832157{3}[source]
I won't mention telnet because you don't use it, but in CSV and similar data it is quite a trouble to normalize the data. So instead of 2 possibilities now we 3 to detect.
replies(2): >>41832526 #>>41832567 #
7. nightpool ◴[] No.41832526{4}[source]
I have never had any issues with this using a standards compliant CSV parser.
replies(1): >>41850490 #
8. viraptor ◴[] No.41832567{4}[source]
I don't get the CSV part. You can emit a new row after a line ending and on EOF with non-empty buffer. What's the tricky part or third option here? The crlf is never a part of the data.
9. tryauuum ◴[] No.41832819[source]
I do like concatenating files with cat, and if a file has its final line not ending in newline symbol the result is ugly.

I know it's just me but my worldview is that the world would be better if all editors had "insert final newline" behavior

replies(1): >>41832858 #
10. perching_aix ◴[] No.41832858{3}[source]
My problem is that what I input (and observe!) doesn't match what's persisted. Worse still, editors lie about it to me until I close the file and reopen it. And just to really turn the knife, various programs will then throw a fit that a character that I did not input and my editor lies about not being present, is present. I hope it's appreciable why I find this frustrating.

I expect my editor to do what I say, not secretly(!) guess what I might have wanted, or will potentially want sometime in the future. Having to insert a newline while concatenating files is a chore, but a predictable annoyance. Having to hunt for mystery bytes, maybe less so.

replies(2): >>41833180 #>>41834447 #
11. bityard ◴[] No.41833180{4}[source]
I have been using and programming Unix systems for almost 30 years and have not run into anything like what you are describing.

What Unix program "throws a fit" when encountering a perfectly normal newline in the last line in a file?

replies(1): >>41833263 #
12. perching_aix ◴[] No.41833263{5}[source]
"Unix programs" I haven't ran into throwing a fit per se. That's why I didn't write that.

What I ran into issues with was contemporary software that's shipped to Linux, such as Neo4j, which expects its license files to have no newline at the end of the file, and will actively refuse to start otherwise.

I have a feeling I'll now experience the "well that's that software's problem then" part of this debate. Just like how software not being able to handle CRLF / CR-only / LF-only, is always the problem - instead of text files being a joke, and platforms assuming things about them being the problem.

13. eviks ◴[] No.41834447{4}[source]
Wait, are they're no editors that don't lie to you?
14. nunobrito ◴[] No.41850490{5}[source]
Absolutely correct: You never had issues. Other people have built other software that does not use modern CSV libraries. They work just fine today and don't need to update, wouldn't even be possible for most cases in either case.

Please do consider that many software products will not change and they will still be actively used on production environments that you will never have interest about.

replies(1): >>41852209 #
15. nightpool ◴[] No.41852209{6}[source]
Well, GP proposed removing the idea of trailing newlines from standard *nix tools entirely, so I think it's fair to ask what shop is going to update their RHEL deployment to upgrade to a version of `cat` or `sed` that doesn't have trailing newlines but can't spend 5 minutes to handle a newline properly in their CSV parser? That doesn't make a lot of sense.

And it was pretty clear from the context of norir's comment that they were not talking about legacy software, they were talking about writing new projects/file formats that used newlines as a separator. Just because you want to shoehorn your legacy projects into this discussion doesn't mean that they fit.