[pve-devel] appllied: [PATCH] read firstline: only map ENOENT to undef, raise error otherwise

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Jun 13 07:32:57 CEST 2023

Am 13/06/2023 um 07:27 schrieb Dietmar Maurer:
>> One could argue that the case for not existent should return undef,
>> while an empty file should return an empty string, but for that we
>> might want to check all use-sites first.
> AFAIR I use this function many times assuming that it does not throw errors in case of empty files. That is quite convenient.

Yes, and it still doesn't errors in that case. Above is talking about differentiating
the not-existing, empty file and empty first-line cases.

Currently (and before my patch) the behavior is:

- file does not exist -> undef
- file exists but empty -> undef
- file exists but first line empty -> ''

It would be a bit more expected to have the "file exists but empty" case also return
an empty string, but it probably doesn't matter.

More information about the pve-devel mailing list