bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: proposed improvement of diagnostics for missing/extra operands


From: Jim Meyering
Subject: Re: proposed improvement of diagnostics for missing/extra operands
Date: Thu, 10 Jun 2004 18:59:31 +0200

Paul Eggert <address@hidden> wrote:
> A few years ago somebody (I forgot who) suggested that "diff" output

Maybe Karl Berry?
I've made a few such changes based on suggestions from him.

> messages like this when given too few or too many args:
>
>    $ diff a
>    diff: missing operand after `a'
>    diff: Try `diff --help' for more information.
>    $ diff a b c
>    diff: extra operand `c'
>    diff: Try `diff --help' for more information.
>
> For new users, this gives more information than just saying "too few
> operands" or "too many operands".  I installed this behavior into
> diffutils 2.7.2 and it has seemed to work pretty well in practice, and
> I'd like to propose similar behavior for coreutils.
>
> In a few cases this will cause new diagnostics to lack some
> information that is present in the old, e.g.:
>
>    old output of "tr -d a b":
>
>       tr: only one string may be given when deleting without squeezing repeats
>
>    new output of "tr -d a b":
>
>       tr: extra operand `b'
>       Try `tr --help' for more information.
>
> but I think the new behavior is better anyway, as its uniformity will
> cause people to recognize the symptoms from similar failures in other
> commands.

Thanks for the patch!
I have mixed feelings about it.
In cases where the change is from a mere `too many arguments' to the
more-informative `extra operand 'FOO'', it is obviously for the better.

Here are some cases where it is less obvious:

  cur$ md5sum --check f a
  md5sum: only one argument may be specified when using --check
  new$ ./md5sum --check f a
  ./md5sum: extra operand `a'

  cur$ cp
  cp: missing file argument
  new$ ./cp
  ./cp: missing operand after `./cp'

  cur$ cp a
  cp: missing destination file
  new$ ./cp a
  ./cp: missing operand after `a'

And if I happen to be using `mv' via an alias like `mv -i',
then I get this:

  new$ alias mv='command mv -i'
  new$ PATH=. mv
  mv: missing operand after `-i'

I prefer the current diagnostic:

  cur$ mv
  mv: missing file argument

Going a little overboard, it can get a ugly if getopt
ends up reordering arguments:

  new$ ./mv a --force
  ./mv: missing operand after `a'

Consistency is nice, but the above feel like regressions to me.
Other opinions welcome.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]