Re: stat(1) isn't honouring locale

From: Stefan Esser <se_at_freebsd.org>
Date: Sat, 30 Oct 2021 18:31:31 UTC
Am 30.10.21 um 14:12 schrieb Jamie Landeg-Jones:> Stefan Esser <se@freebsd.org>
wrote:
>
>>> % date +%+
>>> Fri 29 Oct 2021 00:15:05 BST
>>>
>>> % stat -t%+ -f '%Sm' .
>>> Fri Oct 29 00:13:38 BST 2021
>>> -----------------------------
>
>> thank you for reporting this issue and suggesting a fix.
>>
>> I have committed your proposed fix to -CURRENT as Git commit
>> 20f8331aca892ff8
>> and plan to MFC it to 13-STABLE in a few days.
>>
>> I'm CCing to the release engineer, since this might be a change that
>> we want to include in the upcoming 12.3 release (currently in beta).
>
> Thanks, and thanks for the quick response! I wasn't sure if it was an
> oversight,> or if there was something I missed.

The man page does not mention a locale dependency, and strftime()
without setting a locale just returns the date for the POSIX locale.

But I think that it was an oversight, since the date command respects
the locale by default and with the change you suggested, it is possible
to get the stat output in the locale specific format but also in the
format previously displayed.

This might be a change that violates POLA, since a format changes in
an existing application, and I'm not sure whether a MFC to 12.3 might
be too large a change at that time of the release cycle.

If it is merged to 13-STABLE I'll add a "add to release notes" marker.

But I do think that this is a worthwhile change that has just been
forgotten when other utilities have been made locale aware.

Regards, STefan