News for hackers. Stuff that matters.
Re:Regex character "$" doesn't mean "end-of-string" by coryrc on Wednesday March 20, 2024 @12:19PM (#39768671)
Pedantically, if it doesn't end with a newline, it's considered a binary file and not a text file. Binary files don't have lines.

In practice, most utilities expecting text files will still operate on it.

Re:Regex character "$" doesn't mean "end-of-string" by PaulDavisThe1st on Wednesday March 20, 2024 @01:41PM (#39769787)
No file has lines.

"Lines" are a convention established by (or not) software reading a data stream.

Re:Regex character "$" doesn't mean "end-of-string" by coryrc on Wednesday March 20, 2024 @03:16PM (#39770824)
Ackshully
Re:Regex character "$" doesn't mean "end-of-string" by wtetzner on Friday March 22, 2024 @09:54AM (#39790806)
That's a weird way to look at it. Binary files might not have "lines", but there's no reason they couldn't include a byte with value 10 (the ASCII value for \n). Software reading that file wouldn't know the difference, right?

Also, why couldn't you have a text file without any lines?

Re:Regex character "$" doesn't mean "end-of-string" by coryrc on Friday March 22, 2024 @06:35PM (#39795568)
All I'm addressing is GP's comment:

    It's a file with zero complete lines. But it has 1 line, that's incomplete, right?
Because the Unix definition of text file requires the file to end with a newline. "Lines" only exist in the context of text files. If there's no terminating newline, it's (pedantically) not a text file and so has no lines. Now, in practice, if you open() that file in text mode, it doesn't TMK return an error if the terminating newline isn't present, but it's undefined behaviour.

And if you do have a terminating newline, then you have at least one line :).