[Toybox] Defect in Argument parsing for "#" and "-"

Rob Landley rob at landley.net
Wed Jul 4 11:11:32 PDT 2012


On 07/03/2012 11:49 PM, Ashwini Sharma wrote:
>> I can grab a third character (maybe %) for literal long. The tradeoff
>> here is between generic behavior (which can share code) and precise
>> behavior that does exactly what you want. Some things need suffixes, so
>> I made everything accept suffixes by default because I didn't see the
>> harm. Apparently you do. Could you explain the harm to me?
> 
>  I was looking at this from the perspective where I do not want any
> alpha chars for the argument, not even Suffixes. Else I don't see any
> harm in it.

The user is never _required_ to supply alpha characters, and if they do
so anywhere but the very end it'll barf.

It does impose a format.  If you go "32kk" it'll barf, same with "3k2".
(I can fix treating an empty string as zero that was an oversight.)

So if I implement a '%' arg type, it this will add extra code for a mode
that does less. It wouldn't elimiate the old '#' mode that accepts
suffixes, because some commands are required to accept suffixes (for dd
and truncate it's apparently a gnuism but split -b has it in posix.)

It's possible this is the correct thing to do anyway, but that implies
gnu was wrong to add it to dd if posix didn't specify. My theory was
"since I already wrote the code, it doesn't cost extra to use it, and
consistent behavior is good". I'm open to counter-examples...

Rob
-- 
GNU/Linux isn't: Linux=GPLv2, GNU=GPLv3+, they can't share code.
Either it's "mere aggregation", or a license violation.  Pick one.

 1341425492.0


More information about the Toybox mailing list