coreutils
[Top][All Lists]
Advanced

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

Re: who: sorted output + minor usage change


From: Pádraig Brady
Subject: Re: who: sorted output + minor usage change
Date: Mon, 09 Feb 2015 10:49:46 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0

On 07/02/15 13:46, Pádraig Brady wrote:
> On 07/02/15 02:04, Assaf Gordon wrote:
>> Hello,
>>
>> Two suggestions for 'who':
>>
>> first,
>> the --help text for '-u/--users' option is not clear (IMHO).
>>
>> 'who --help' says:
>>     -u, --users       list users logged in
>>
>> Whereas the Coreutils manual says:
>> "-u => After the login time, print the number of hours and minutes that the 
>> user has been idle. [...]"
>>
>> And posix says ( 
>> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/who.html ):
>> "-u => Write "idle time" for each displayed user in addition to any other 
>> information. [...]".
>>
>> so, except in the --help text, it talks about showing idle time.
>> Perhaps consider slightly modifying the usage text? (that's the first patch 
>> attached).
>>
>>
>> second,
>> would you consider adding a 'sort' option to sort output by different fields?
>> The attached patch implements this.
>> examples:
>>    who -a --sort=idle
>>    who -a --sort=name
>>    who -a --sort=line
>>
>> Normally, piping to 'sort' should be enough, but the fields output by 'who' 
>> are not fixed, so sorting with whitespace delimiters is tricky,
>> and sorting by exact character position is messy, and depends on the option 
>> used.
>> Also, for sorting by idle time, the field conains mixed digits and 
>> characters (e.g. "." for recently active, and "old" for not active) - not 
>> easily sorted.
> 
> Initially I thought this was overkill.
> Though the sorting is in place and so as scalable as it was previously.
> Also sorting existing output is very difficult as you say.
> So +1 from me.

On third thought, perhaps we should tweak the output from who to be more easily 
processed?
It seems like small tweaks could improve things a lot, and would be a more 
general solution.
Also the current implementation reads all entries up front, but that's 
currently an implementation detail,
which internal sorting would greatly complicate if we ever wanted to change.
The time field can already be sorted with `sort -b -k3,4` (we should remove the 
locale variant)
The idle time already sorts well in ASCII order wrt '.' "HH:mm" 'old'.
We should output placeholders for empty fields.
The only caveat is that -T says to use a space to indicate the entry is not 
associated with a terminal,
but we could change that to '.' unless POSIXLY_CORRECT was set.

cheers,
Pádraig




reply via email to

[Prev in Thread] Current Thread [Next in Thread]