[TUHS] Command line options and complexity

Steve Nickolas usotsuki at buric.co
Thu Mar 12 10:53:12 AEST 2020

On Thu, 12 Mar 2020, Greg 'groggy' Lehey wrote:

> On Wednesday, 11 March 2020 at 14:18:08 +1100, Dave Horsfall wrote:
>> The "ls" command for example really needs an option-ectomy; I find that I
>> don't really care about the exact number of bytes there are in a file as
>> the nearest KiB or MiB (or even GiB) is usually good enough, so I'd be
>> happy if "-h" was the default with some way to turn it off (yes, I know
>> that it's occasionally useful to add them all up in a column, but that
>> won't tell you how many media blocks are required).
> A good example.  But you're not removing options, you're just
> redefining them.  In fact I find the -h option particularly emetic, so
> a better choice in removing options would be to remove -h and use a
> filter to mutilate the sizes:
>  $ ls -l | humanize
> But that's a pain, isn't it?  That's why there's a -h option for
> people who like it.  Note that you can't do it the other way round:
> you can't get the exact size from -h output.
> And then there's the question why you don't like the standard output.
> Because the number strings are too long and difficult to read, maybe?
> That's the rationale for the -, option.
>> Quickly now, without looking: which option shows unprintable
>> characters in a filename?  Unless you use it regularly (in which
>> case you have real problems) you would have to look it up; I find
>> that "ls ... | od -bc" to be quicker, especially on filenames with
>> trailing blanks etc (which "-B" won't show).
> This is arguably a bug in the -B option.  I certainly don't think the
> pipe notation is quicker.  But it's nice to have both alternatives.
> Greg
> --
> Sent from my desktop computer.
> Finger grog at lemis.com for PGP public key.
> See complete headers for address and phone numbers.
> This message is digitally signed.  If your Microsoft mail program
> reports problems, please read http://lemis.com/broken-MUA

I went through all the switches defined by POSIX, and figured that those 
26 could be cut down.  My concept reduced the number of switches from 26 
to 9 (FLRadfiln).  Of course, the idea is to be more minimalist than 
POSIX, so some people's opinions on what is or isn't necessary may differ 
from mine.

Of course, this changes the default behavior of ls because it no longer 
would be able to do columnar listings (|column for that).

I felt -A was a redundant "almost -a".
I felt -C and -x were redundant because a tool like column(1) could be 
used to do the same job (even though column(1) isn't POSIX).
I felt -H was a redundant "almost -L".
I felt -S, -r and -t could be implemented in other ways using sort(1).
I felt -c and -u were meaningless, but that's because of the filesystems I 
usually work with that do not have functional equivalents.  -u for one is 
completely useless on VFAT even though it has such timestamps!  YMMV.
I felt -g and -o could be replaced by cut(1).
I felt -k wasn't really all that important.  Just halve the numbers.
I felt -m wasn't really all that important.  There's other ways to convert 
to that format, no doubt, through filters.
I felt -p was a redundant "almost -F".
I felt -q could be done just fine with something like tr(1).
I felt -s was a redundant "kindasorta -l".
And -1 becomes the new default, so it's redundant. ;)

Again, YMMV. ;)


More information about the TUHS mailing list