Re: A simple hate today.

[prev] [thread] [next] [lurker] [Date index for 2006/05/27]

From: H.Merijn Brand
Subject: Re: A simple hate today.
Date: 11:01 on 27 May 2006
On Fri, 26 May 2006 21:42:25 +0100, David Cantrell <david@xxxxxxxx.xxx.xx>
wrote:

> On Fri, May 26, 2006 at 02:04:53PM +0200, H.Merijn Brand wrote:
> > On Fri, 26 May 2006 03:35:44 -0700, jrodman@xxxx.xxxxxxxxxx.xxx wrote:
> > > Here, let me plant a bomb on our shared computer:
> > >     touch /tmp/-r
> > > It may take a long time to go off, but if it does, I guess that's your
> > > fault too?
> > No it's yours. *YOU* planted the bomb.
> > You cannot blame someone using a train for a bomb a terrorist planted.
> 
> It's not about blame.  It's about who suffers.  In this case *you*
> suffer from *his* actions because you use a character which has special
> meaning to the shell, and you don't want that.

I don't suffer, because I have protected myself (as much as possible) against
that. At the end, no-one really cares about the victim, and all blame the
attacker.

Anyway, My plea was not about how shells interpret -?, but that programs
should support it as alias for --help. -\? is still a lot less characters
than --help, and IMHO still evenly clear.

OK, I've learned a lot from all the opinions raised in this hate, and I will
continue to support *both* --help and -? for all my scripts. There is no
harm  nor security issue from the script/program side of that.

I still have no intention to have support for -h. To *me* it is an illogical
choice and I am likely to choose that letter for something else.

I will probably review my scripts to

  * send a requested help to STDOUT, and exit with 0
  * send error help to STDERR, and exit with non-null
  * think about the error message regarding how help should be asked for

Most likely that will end up with a construct like

--8<---
use strict;
use warnings;

sub usage ($)
{
    my $err = shift and select STDERR;
    print "usage: ...";
    exit $err;
    } # usage

@ARGV == 1 and $ARGV[0] eq "-?" || $ARGV[0] =~ m/^-+help$/ and usage (0);

use Getopt::Long qw(:config bundling nopermute);
my $opt_v = 0;
GetOptions (
    "v:1" => \$opt_v,
    ) or usage (1);
-->8---

Sounds sane?

if someone sees the need to extend that with -h, for whatever reason, that is
easy done in the GetOptions

    "h|aide|hilfe" => sub { usage (0) },

-- 
H.Merijn Brand        Amsterdam Perl Mongers (http://amsterdam.pm.org/)
using & porting perl 5.6.2, 5.8.x, 5.9.x  on HP-UX 10.20, 11.00, 11.11,
& 11.23, SuSE 10.0, AIX 4.3 & 5.2, and Cygwin.       http://qa.perl.org
http://mirrors.develooper.com/hpux/           http://www.test-smoke.org
                       http://www.goldmark.org/jeff/stupid-disclaimers/

Generated at 09:00 on 29 May 2006 by mariachi 0.52