Re: A simple hate today.

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

From: H.Merijn Brand
Subject: Re: A simple hate today.
Date: 20:43 on 25 May 2006
On Thu, 25 May 2006 21:12:39 +0200, Juerd <juerd@xxxxxxxxxxx.xx> wrote:

> H.Merijn Brand skribis 2006-05-25 18:19 (+0200):
> > IMHO it should be either -? or --help, and -help could be acceptable
> 
> -? is silly. In most shells, it's a glob match, and is passed to the
> program only if it didn't match.
> 
> I couldn't easily find any program that supports -?...
> 
> juerd@nano:~$ ls -?
> ls: invalid option -- ?
> Try `ls --help' for more information.
> juerd@nano:~$ grep -?
> grep: invalid option -- ?
> Usage: grep [OPTION]... PATTERN [FILE]...
> Try `grep --help' for more information.
> juerd@nano:~$ du -?
> du: invalid option -- ?
> Try `du --help' for more information.
> juerd@nano:~$ cp -?
> cp: invalid option -- ?
> Try `cp --help' for more information.
> juerd@nano:~$ mv -?
> mv: invalid option -- ?
> Try `mv --help' for more information.
> juerd@nano:~$ mkdir -?
> mkdir: invalid option -- ?
> Try `mkdir --help' for more information.
> juerd@nano:~$ perl -?
> Unrecognized switch: -?  (-h will show valid options).
> juerd@nano:~$ ed -?
> ed: invalid option -- ?
> Try `ed --help' for more information.
> juerd@nano:~$ vi -?
> VIM - Vi IMproved 6.4 (2005 Oct 15, compiled Apr 28 2006 01:45:37)
> Unknown option: "-?"
> More info with: "vim -h"
> juerd@nano:~$ yes -?
> yes: invalid option -- ?
> Try `yes --help' for more information.
> juerd@nano:~$ awk -?
> awk: not an option: -?
> juerd@nano:~$ python -?
> Unknown option: -?
> usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
> Try `python -h' for more information.
> juerd@nano:~$ ruby -?
> ruby: invalid option -?  (-h will show valid options)

All GNU, as Philip said.

d3:/usr/bin 105 > ls -?
ls: illegal option -- ?
usage: ls -1ARadeCxmnlogrtucpFLbqisf [files]
d3:/usr/bin 106 > grep -?
grep: illegal option -- ?
usage: grep [-E|-F] [-c|-l|-q] [-binsvx] -e pattern_list...
        [-f pattern_file...] [file...]
usage: grep [-E|-F] [-c|-l|-q] [-binsvx] [-e pattern_list...]
        -f pattern_file... [file...]
usage: grep [-E|-F] [-c|-l|-q] [-binsvx] pattern [file...]
d3:/usr/bin 107 > du -?
du: illegal option -- ?
usage: du [-a|-s] [-kbrx] [-t type] [name ...]
d3:/usr/bin 108 > cp -?
cp: illegal option -- ?
Usage:  cp [-f|-i] [-p] [-S] [-e warn|force|ignore] source_file target_file
        cp [-f|-i] [-p] [-S] [-e warn|force|ignore] source_file ... target_directory
        cp [-f|-i] [-p] [-S] -R|-r [-e warn|force|ignore] source_directory ... target_directory
d3:/usr/bin 109 > mkdir -?
mkdir: illegal option -- ?
usage: mkdir [-p] [-m mode] dirname ...
d3:/usr/bin 109 > mkdir -?
mkdir: illegal option -- ?
usage: mkdir [-p] [-m mode] dirname ...
d3:/usr/bin 110 > ed -?
ed: illegal option -- ?
d3:/usr/bin 111 > ./vi -?
vi: illegal option -- ?
d3:/usr/bin 112 > sh -?
-?: A specified flag is not valid for this command.

Look, here is a genuine old awk and sed :)

d3:/usr/bin 113 > awk -?
Usage: awk [-F fs][-v Assignment][-f Progfile|Program][Assignment|File] ...
d3:/usr/bin 114 > sed -?
Usage: sed [-n] [-e script] [-f source_file] [file...]


I don't have Ruby or Python installed

csh is funny. It just ignores it and starts

d3:/usr/bin 117 > csh -?
%

Echo is also OK
d3:/usr/bin 123 > echo -?
-?

Some *very* old commands:
d3:/usr/bin 133 > metamail -?
Usage:  metamail [-b] [-B] [-d] [-e] [-h] [-r] [-R] [-p]  [-P] [-x] [-y] [-z] [-c content-type] [-E content-transfer-encoding] [-f from-name] [-m mailername] [-s subject] [message-file-name]

d3:/usr/bin 134 > elmalias -?


Usage: elmalias    [ -c alias-list | -q ]
   or  elmalias -l [ regular-expression ]

         -c alias-list   checkalias - check to see if an alias is defined.
         -l expression   listalias - list user and system alias.
         -q              systemalias - install system-aliases.

d3:/usr/bin 142 > rup -?
Usage: rup [-h] [-l] [-t] [host ...]

d3:/usr/bin 147 > jobs -?
Usage: jobs [ -l ].

> I found a few things that do support it, for some values of support.
> The most likely reason for -? to work is that a program always gives
> help when you use an unknown option (mount, ps). And sometimes it works,
> but isn't documented (zip, gzip, firefox).
> 
> The only programs I could find that officially support this are abiword,
> activation-client (some gnome thing), aspell, botti, epydocgui,
> fc-{cache,list,match}, gconftool, gdm-signal, getent, gij,
> gtk-update-icon-cache, h2xs, iconv, inkscape, irssi, java, less,
> locale{,def}, nano, nmblookup, oo{base,calc,draw,ffice,fromtemplate,
> impress,math,web}, pango-{querymodules,view}, pdbedit, pdf{fonts,images,
> info,toppm,tops,totext}, pico, pon, profiles, rpcclient,
> smb{cacls,control,get,mount,spool,client,cquotas,mnt,status,tree},
> synclient, wvdial{,conf}, xkb{comp,evd,print}
> 
> I suspect you have something to do with the introduction of -? into
> h2xs, in between perl 5.7.2 and 5.7.3 :)

No, I didn't, but I proposed a change to perl a very long time ago, and I
still don't understand why it was turned down.

> So that's about 60 programs that do support -?, against over 1200 that
> do not. Sanity wins!

Again, you're in a GNU environment.

> > For me, -h never has meant help, nor do I expect *any* command or util to
> > show me help on -h
> 
> Many, many more programs have -h bound to help, compared to those that
> support -?.

I'll remember that. Maybe even IBM and HP will listen :p

Now, come up with a good reason why -? should not map to --help
Instead of barfing with unsupported option. Shell escaping is NOT a good
reason, as the people that suffer from that don't use it anyway.
-? as an alias for --help makes sense. I ask for help: just give it.

-- 
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/
There's stuff above here

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