darcs

Issue 1336 poor error message on --last "" (empty string to numbers parser)

Title poor error message on --last "" (empty string to numbers parser)
Priority bug Status resolved
Milestone Resolved in
Superseder Nosy List darcs-devel, davidm, dmitry.kurochkin, drewp, jaredj, kowey, thorkilnaur, tux_rocker, twb
Assigned To
Topics ProbablyEasy, UI

Created on 2009-01-29.05:18:38 by drewp, last changed 2009-12-08.15:10:30 by davidm.

Messages
msg7244 (view) Author: drewp Date: 2009-01-29.05:18:36
I pressed enter too early and made this command line:
darcs cha --last=

The error is not so great:
darcs: Prelude.read: no parse

I expected something like "The --last flag requires a value".
msg7525 (view) Author: twb Date: 2009-03-28.11:36:08
On Wed, Jan 28, 2009 at 06:18:36PM +0000, Drew Perttula wrote:
> I pressed enter too early and made this command line:
> darcs cha --last=
> 
> The error is not so great:
> darcs: Prelude.read: no parse
> 
> I expected something like "The --last flag requires a value".

Curiously:

    $ darcs cha --last

    darcs failed:  option `--last' requires an argument NUMBER

    $ darcs cha --last=
    darcs: Prelude.read: no parse
    $

I guess this means the problem is in the piece of code that normalizes
--foo=bar to --foo bar.
msg7569 (view) Author: tux_rocker Date: 2009-03-31.19:52:26
I suspect that GNU getopt happily sends an empty string to the Haskell code, and
the Haskell code then fails to parse that.
msg8111 (view) Author: kowey Date: 2009-08-12.10:50:26
I'll bet this is the problem (Darcs/Arguments.lhs):

number_string :: String -> Int
number_string s = if and (map isDigit s) then read s else (-1)

Looks like we need add

number_string "" = -1

Marking need-implementation (instead of going ahead and just doing it) because
I'd like the implementor to make sure this gives a good result UI-wise and also
consider if we need a special error message for this case. Tests would be nice
too.  Definitely an easy job, even for a Haskell newbie.
msg9563 (view) Author: davidm Date: 2009-12-08.15:10:23
The following patch updated the status of issue1336 to be resolved:

* Resolve issue1336: poor error message on --last "" (empty string to numbers parser) 
Ignore-this: 93b2708bc87ea0a8aefc49732455b14e
History
Date User Action Args
2009-01-29 05:18:38drewpcreate
2009-03-28 11:36:12twbsetstatus: unread -> unknown
nosy: + twb
messages: + msg7525
2009-03-31 19:52:28tux_rockersetpriority: bug
nosy: + tux_rocker
messages: + msg7569
2009-08-12 10:50:32koweysetstatus: unknown -> needs-implementation
nosy: + jaredj
topic: + ProbablyEasy, UI
messages: + msg8111
2009-08-12 10:51:49koweysetnosy: kowey, simon, twb, drewp, thorkilnaur, jaredj, tux_rocker, dmitry.kurochkin
title: poor error message on corrupt cmdline -> poor error message on --last "" (empty string to numbers parser)
2009-08-25 17:40:12adminsetnosy: + darcs-devel, - simon
2009-08-27 14:23:38adminsetnosy: kowey, darcs-devel, twb, drewp, thorkilnaur, jaredj, tux_rocker, dmitry.kurochkin
2009-11-24 00:41:55koweylinkpatch77 issues
2009-12-08 15:10:31davidmsetstatus: needs-implementation -> resolved
nosy: + davidm
messages: + msg9563