coreutils
[Top][All Lists]
Advanced

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

Re: [coreutils] [PATCH] head: optionally indicate underrun of set limit


From: Jim Meyering
Subject: Re: [coreutils] [PATCH] head: optionally indicate underrun of set limit
Date: Tue, 23 Nov 2010 17:53:04 +0100

Pádraig Brady wrote:

> On 23/11/10 16:24, Stefan Tomanek wrote:
>> Dies schrieb Stefan Tomanek (address@hidden):
>>
>>> It is often convinient to detect whether head has in fact printed the
>>> requested number of lines or if EOF was reached before reaching that
>>> point. This patch adds the option --indicate-underrun, which makes
>>> "head" exit with a status of 4 instead of 0 if no more data could be
>>> read from its input.
>>
>> Any thoughts about this change? It's a rather small patch, but would
>> be quite useful (at least for me).
>
> This does seem useful on the face of it.
> I need to do a little further investigation
> to see if there are existing ways to achieve the same.

For the record, here's a quick one-liner:

  $ seq 2|perl -ne '$n=3; print; $.==$n and $ok=1,last; END{exit 4*!!$ok}'
  1
  2
  $ seq 5|perl -ne '$n=3; print; $.==$n and $ok=1,last; END{exit 4*!!$ok}'
  1
  2
  3



reply via email to

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