NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/40337: Proposed localized change to w(1)/uptime(1)



The following reply was made to PR bin/40337; it has been noted by GNATS.

From: Matthew Mondor <mm_lists%pulsar-zone.net@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: dholland-bugs%NetBSD.org@localhost
Subject: Re: bin/40337: Proposed localized change to w(1)/uptime(1)
Date: Sun, 15 Feb 2009 00:11:12 -0500

 On Sat, 14 Feb 2009 22:35:02 +0000 (UTC)
 David Holland <dholland-bugs%netbsd.org@localhost> wrote:
 
 >  So, because this changes the default output formatting in a program
 >  that's fairly often used in scripts, I don't think it's a great idea.
 
 True, this makes it a bit more complex
 
 >  Unfortunately, strftime does not define a "short time" format that
 >  would naturally produce %l:%M%p in the default locale. Probably it
 >  should, but we don't really get to decide that.
 >  Maybe a suitable hack would be to teach w which locales want %k:%M
 >  instead of %l:%M%p? Is there any other alternative formatting that
 >  anyone might (reasonably) want?
 
 %X wouldn't be suitable for that "short time"?
 
 I just checked what might be ideal for scripts but I'm surprised
 uptime(1) doesn't allow date(1)-like format argument using strftime(3),
 an argument to chose between 24h/12h time nor an argument to return the
 uptime expressed in seconds.  Assuming these would exist, scripts would
 no longer need to parse locale-specific output...
 
 I checked on a Debian system and uptime appears to return the C/POSIX
 LC_TIME format with any locale set:
 23:33:03 up 2 days,  3:18,  3 users,  load average: 0.14, 0.05, 0.01
 
 Versus ours:
 11:34PM  up 3 days,  4:07, 8 users, load averages: 0.03, 0.02, 0.00
 
 I couldn't check the output on OpenBSD and FreeBSD.  It should be noted
 that the proposed change affects the returned current time and not the
 actual uptime output, for which scripts may already use date(1)...
 Some might still argue that under some locales a comma should be used
 instead of a dot (i.e. LC_NUMERIC=fr_CA) for load averages, but this
 change wouldn't address this.
 
 I actually have no strong opinion about this however, I filed the PR
 after noticing a complaint from a user on IRC.  If it makes better
 sense not to localize uptime or w output let's leave them as-is, of
 course.
 
 Admitedly, there are many non-localized cases in the base system, as
 well as missing support for many languages (and this is not a problem
 at all when using popular desktop software).  Fixig all cases is
 probably significant work, i.e. suitable for a hackathon, if core
 decides it's a good decision, and this PR is only nitpicking at one
 particular example while not solving much.
 
 As for obtaining the uptime in a sane manner for scripts if they'd want
 to avoid parsing inconsistent strings, a sysctl returning uptime in
 seconds might also be a better solution than adding a format option to
 uptime(1) (on this 5.0RC2 box I see no such uptime but there is
 boottime, expressed as a POSIX-locale timestamp, which is probably
 consistent enough for scripts too).
 
 Thanks,
 -- 
 Matt
 


Home | Main Index | Thread Index | Old Index