4 ms·
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
by coryrc 3y ago
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 :).