[Bug 276304] w(1) with produces invalid JSON output with --libxo json parameter on Croatian locale

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 13 Jan 2024 20:12:15 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=276304

            Bug ID: 276304
           Summary: w(1) with produces invalid JSON output with --libxo
                    json parameter on Croatian locale
           Product: Base System
           Version: 14.0-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: vedran@miletic.net

% w --libxo json
{"uptime-information": {"time-of-day":"
9:01PM","uptime":2667682,"days":30,"hours":21,"minutes":1,"seconds":22,"uptime-human":"
30 days,
21:01,","users":2,"load-average-1":0,25,"load-average-5":0,34,"load-average-15":0,30,
"user-table": {"user-entry":
[{"user":"vedranm","tty":"pts/1","from":"p508c7e40.dip0.t-ipconnect.de","login-time":"
8:44PM","command":"w --libxo json"},
{"user":"vedranm","tty":"pts/2","from":"tmux(40223).%0","login-time":"čet01PM","idle":20,"command":"btop"}]}}}

This is not valid JSON. One can notice the values 0,25, 0,34, and 0,30; number
separator is printed as comma, while JSON requires the dot to be used
regardless of locale. Setting locale to en_US.utf-8 like

% env LC_ALL=en_US.utf-8 w --libxo json

will produce correct result. Other comands, such as ps, output numbers with
decimals as strings (bug 265223) and avoid this issue.

-- 
You are receiving this mail because:
You are the assignee for the bug.