stat(1) isn't honouring locale
- Reply: Stefan Esser : "Re: stat(1) isn't honouring locale"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 29 Oct 2021 18:15:10 UTC
stat(1) isn't honouring locale.
The manual page says:
-t timefmt
Display timestamps using the specified format. This format is passed directly to strftime(3).
strftime(3) says:
%+ is replaced by national representation of the date and time (the format is similar to that produced by date(1)).
However:
-----------------------------
% date
Fri Oct 29 00:14:12 BST 2021
% date +%+
Fri Oct 29 00:14:19 BST 2021
% stat -t%+ -f '%Sm' .
Fri Oct 29 00:13:38 BST 2021
-----------------------------
% setenv LANG en_GB.UTF-8
% date
Fri 29 Oct 2021 00:14:57 BST
% date +%+
Fri 29 Oct 2021 00:15:05 BST
% stat -t%+ -f '%Sm' .
Fri Oct 29 00:13:38 BST 2021
-----------------------------
Including <locale.h> and adding:
(void) setlocale(LC_TIME, "");
before the call to strftime() in usr.bin/stat/stat.c fixes this
Is there any reason this isn't in place?
Cheers, Jamie