Subject: Re: du(1) with gigabyte option.
To: None <mouse@Rodents.Montreal.QC.CA>
From: Ben Harris <bjh21@netbsd.org>
List: tech-userlevel
Date: 02/21/2003 11:44:13
In article <200302210858.DAA18771@Sparkle.Rodents.Montreal.QC.CA> you write:
>>> Second, since -m and -g are nonportable anyway, why not let -k take
>>> an argument?  That way, -km, -kg, -kt, etc. work (with -k retaining
>>> its current meaning).
>> You can't do that, arguments are not allowed to be optional.
>
>...??  Who's to allow or disallow?  I've seen flags with optional
>arguments.  (Not often, but occasionally.)
>
>I see no reason this couldn't be treated as four different flags - -k,
>-km, -kg, and -kt, each with its own meaning (which just happen to be
>closely related).

You could do that, but it wouldn't gain anything in portability, since all
other versions of du (including POSIX) would interpret "-km" as "-k -m", so
we'd be incompatible with any du that added a -m (or -g, -t, -p, -e, -z or
-y) option, precisely as if we'd added a -m (or -g, etc) option ourselves.

I'd be inclined to follow GNU du here if you want to do this as an option
rather than an environment variable.  They'd have you do -B1K, -B1M, -B1G
etc.  You could extend this so that -BK, -BM, -BG did the same thing if you
object to the extra typing.

-- 
Ben Harris                                                   <bjh21@netbsd.org>
Portmaster, NetBSD/acorn26           <URL:http://www.netbsd.org/Ports/acorn26/>