[Pdx-pm] Getopt::Modern usage model

Michael G Schwern schwern at pobox.com
Fri Jun 10 07:01:09 PDT 2005

On Fri, Jun 10, 2005 at 12:39:05AM -0700, Eric Wilhelm wrote:
> I think the best way of knowing is to not go there.  --this '~' allows 
> the user to be very clear about what they mean and I don't see why any 
> program or module should second-guess that.  If --this=~ is supposed to 
> be treated in a special way (which is actually a work-around to the way 
> the shell treats words), then I don't think it's going to be worth the 
> extra code.

I'd say the behavior of --this ~ vs --this=~ isn't your problem, its a
Unix shell issue.  And your module will work the same as every other Unix
program in this regard.  So just punt.

Here's another way of looking at it.

Let's consider what happens if --foo=~ is disallowed from the user's 
perspective.  Presumably there's going to be some sort of error message.

	$ program --foo=42
	'--foo=bar' form not allowed.  Please use '--foo bar' instead.

At which point the user will say "What the hell?!?" and kick, scream and
curse at the draconian program author.  The program obviously went through
the trouble to parse --foo=42 properly but then refuses to DWIM.

This reminds me of this Python annoyance.

$ python
Python 2.3.5 (#1, Apr  4 2005, 18:50:09) 
[GCC 3.3 20030304 (Apple Computer, Inc. build 1671)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit
'Use Ctrl-D (i.e. EOF) to exit.'
>>> quit
'Use Ctrl-D (i.e. EOF) to exit.'

It knows perfectly well what I meant yet refuses to DWIM.

Since --foo=~ is the only gotcha here and 99% of the time the right thing
to do is to translate it with s/^~/$ENV{HOME}/ if $ENV{HOME} then why not
do that by default and provide a way for the program author to turn it off
in the rare cases where its not needed?

Michael G Schwern     schwern at pobox.com     http://www.pobox.com/~schwern
Just call me 'Moron Sugar'.

More information about the Pdx-pm-list mailing list