Subject: bug#17145: head fails with implicit stdin on darwin

From: Pádraig Brady <[email-masked]>
Date: Tue, 01 Apr 2014 00:14:04 +0100

Very nice cleanup. Comments below...

On 03/31/2014 08:43 PM, Paul Eggert wrote:
> diff --git a/NEWS b/NEWS

> +  head no longer assumes that lseek fails on unseekable devices.
> +  [bug introduced with the --bytes=-N feature in coreutils-5.0.1]

I slightly prefer my NEWS entry since it details the consequences
rather than the mechanism, and so could be more meaningful to end users.

> @@ -833,14 +802,24 @@ head (const char *filename, int fd, uintmax_t n_units, bool count_lines,
>  
>    if (elide_from_end)
>      {
> -      if (count_lines)
> +      off_t current_pos = -1, size = -1;
> +      if (! presume_input_pipe)
>          {
> -          return elide_tail_lines_file (filename, fd, n_units);
> +          struct stat st;
> +          if (fstat (fd, &st) != 0)
> +            error (0, errno, _("cannot fstat %s"), quotearg_colon (filename));
> +          if (S_ISREG (st.st_mode))

s/if/else if/

Could you also update Denis' current email address in THANKS.in

Otherwise it all looks good.

thanks!
Pádraig.