News for hackers. Stuff that matters.
Re:What's New in POSIX 2024 by WJW on Tuesday October 29, 2024 @07:48AM (#41982900)
Kind of a weird definition indeed. One edge case: the definition states the file must contain characters, so presumably zero length files are out. But then how could you have zero lines?
Re:What's New in POSIX 2024 by rascul on Tuesday October 29, 2024 @08:31AM (#41983203)
An empty file is not hard to make. It's just a matter of creating the file and not writing to it.
Re:What's New in POSIX 2024 by WJW on Tuesday October 29, 2024 @08:56AM (#41983380)
Yes obviously. But the POSIX specification for a "text file" as above is that it contains characters, which an empty file by definition does not. So an empty file cannot be a text file if you read that specification strictly, and therefore you cannot have zero lines in a text file. As soon as you have a single character there is at least one line, and the amount of lines can only stay the same or grow from there.

The definition should read "one or more lines" instead or (probably better) specify that a text file contains "zero or more characters".

Re:What's New in POSIX 2024 by rascul on Tuesday October 29, 2024 @09:43AM (#41983768)
Ahh I see what you're saying. I misunderstood at first.
Re:What's New in POSIX 2024 by Ukv on Tuesday October 29, 2024 @10:19AM (#41984093)
POSIX defines a line as:

> 3.185 Line

> A sequence of zero or more non-<newline> characters plus a terminating <newline> character.

So a file with some characters but no trailing newline is reported by `wc -l` as having zero lines.