Re: inaccurate error message from tail

Jim Meyering <[email protected]> Sun, 29 Sep 2002 20:06:59 +0200
Newsgroups gmane.comp.gnu.textutils.bugs
Message-ID <[email protected]>
Mikko Tuumanen <[email protected]> wrote:
> $ tail --version
> tail (textutils) 2.1
> Written by Paul Rubin, David MacKenzie, Ian Lance Taylor, and Jim Meyering.
>
> Copyright (C) 2002 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> $ tail -c 1,2
> tail: 1,2: is so large that it is not representable
> $ tail -c foo
> tail: foo: invalid number of bytes
>
> Shouldn't that 1,2 give also "invalid numer of bytes" in stead of "too
> large"?

Yes, indeed!
Thanks for the report.
I've just fixed that for the upcoming coreutils-4.5.2.
It'll appear here:

  ftp://alpha.gnu.org/gnu/fetish/

Here's the patch:

Index: tail.c
===================================================================
RCS file: /fetish/cu/src/tail.c,v
retrieving revision 1.185
diff -u -p -u -p -r1.185 tail.c
--- tail.c	28 Sep 2002 09:21:17 -0000	1.185
+++ tail.c	29 Sep 2002 18:04:11 -0000
@@ -1460,7 +1460,7 @@ parse_options (int argc, char **argv,
 	    strtol_error s_err;
 	    uintmax_t n;
 	    s_err = xstrtoumax (optarg, NULL, 10, &n, "bkm");
-	    if (s_err == LONGINT_INVALID)
+	    if (s_err != LONGINT_OK)
 	      {
 		error (EXIT_FAILURE, 0, "%s: %s", optarg,
 		       (c == 'n'
@@ -1468,13 +1468,9 @@ parse_options (int argc, char **argv,
 			: _("invalid number of bytes")));
 	      }
 
-	    if (s_err != LONGINT_OK)
-	      error (EXIT_FAILURE, 0,
-		     _("%s: is so large that it is not representable"), optarg);
-
 	    if (OFF_T_MAX < n)
 	      error (EXIT_FAILURE, 0,
-		     _("%s is larger than the maximum file size on this system"),
+		   _("%s is larger than the maximum file size on this system"),
 		     optarg);
 	    *n_units = (off_t) n;
 	  }