Re: [dev] stest review

From: Anselm R Garbe <garbeam_AT_gmail.com>
Date: Sat, 11 Feb 2012 10:29:43 +0100

On 11 February 2012 01:34, Stephen Paul Weber <singpolyma_AT_singpolyma.net> wrote:
> Somebody claiming to be Anselm R Garbe wrote:
>>
>> I heavily dislike the fact that dmenu now contains a reference to
>> getopt(). Not exactly dmenu, but stest.
>>
>> Can we please remove the getopt() dependency?
>
>
> What does the community have against getopt() ?  It certainly beats the
> pants off of writing your own options parser (which almost everyone gets
> wrong) and allows your tool to behave however the local system expects (more
> or less).

I can only speak of myself, not of the the community here. For most
tools the getopt() counterpart of a straight for() option loop (like
found in most suckless.org tools) is much clearer and often even
simpler in my honest opinion.

Using the ARGBEGIN... stuff that Plan 9 (and probably Bell's Unix
implementation (not sure)) incorporates is no better alternative, as
it hides all the ugly work in macros, which makes it a pain to debug
-- in case.

However the real point is that the getopt() style or ARGBEGIN crap
enables and encourages the developer to introduce a bad command flag
interface. Because those approaches hide the utter complexity
involved, the developer tends to care less here. This is my main
argument against getopt() or ARGBEGIN.

If you can write a simple for() loop to process your command line
flags, your interface can't be that hard to grasp for the user.
Otherwise he will look up the weirdo flags quite often in your man
file and develop hate against your tool over time ;)

Cheers,
Anselm
Received on Sat Feb 11 2012 - 10:29:43 CET

This archive was generated by hypermail 2.3.0 : Sat Feb 11 2012 - 10:36:03 CET