ps u formatting with month should depend on locale
It was brought to my attention that in french, strftime's %b
(used for processes which weren't started today in ps u
output) is not necessarily 3 characters long:
$ LANG=fr_FR.UTF-8 ps u
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
username 15137 0.0 0.1 8540 4548 pts/0 Ss déc.01 0:00 -bash
username 23887 0.0 0.1 8544 4712 pts/0 S 02:53 0:00 -bash
username 24049 0.0 0.0 11260 3084 pts/0 R+ 02:54 0:00 ps u
$ LANG=fr_FR.UTF-8 ps -o stime,comm
STIME COMMAND
déc.01 bash
02:53 bash
02:57 ps
(the English output here would be Dec01
, which is just 5 columns)
In this case it probably wouldn't hurt just truncating (although with utf8 we can't just cut at 3 bytes..), but in general I see no guarantee about ABMONTH_{1-12}
length in man nl_langinfo(3)
, so I'm not sure what a good solution would be.
Ideas:
- starting by trying strftime("%b") with all possible months to get how long it should be to decide if we should add extra column width before we start printing the header line doesn't sound like an optimal solution...
- Using our own tm_mon -> string mapping and handling it in our own translation files, making sure all translations are 3 columns wide, is probably better... But doesn't necessarily cover wide languages like Chinese which would be 6-4 columns (3-2 character) or Japanese which prints the number in digit so could be 3 or 4 depending on the month (e.g.
12月
)
It's also probably OK to just say this is how it is and leave it be, I just wanted to bring it to attention.
Edited by Dominique Martinet