GNU bug report logs - #43282
tail -c +N / --bytes +N manpage wrong (off by 1)

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: coreutils; Reported by: "Martin Taibr" <Taibr@HIDDEN>; dated Tue, 8 Sep 2020 15:55:03 UTC; Maintainer for coreutils is bug-coreutils@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 8 Sep 2020 15:54:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 08 11:54:53 2020
Received: from localhost ([127.0.0.1]:56117 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kFfxN-0004H7-90
	for submit <at> debbugs.gnu.org; Tue, 08 Sep 2020 11:54:53 -0400
Received: from lists.gnu.org ([209.51.188.17]:41434)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <Taibr@HIDDEN>) id 1kFfti-0004BF-HY
 for submit <at> debbugs.gnu.org; Tue, 08 Sep 2020 11:51:07 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:34284)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <Taibr@HIDDEN>) id 1kFfti-0007pF-9w
 for bug-coreutils@HIDDEN; Tue, 08 Sep 2020 11:51:06 -0400
Received: from mxb1.seznam.cz ([2a02:598:a::78:89]:45015)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <Taibr@HIDDEN>) id 1kFfte-0003DG-C9
 for bug-coreutils@HIDDEN; Tue, 08 Sep 2020 11:51:06 -0400
Received: from email.seznam.cz
 by email-smtpc22b.ko.seznam.cz (email-smtpc22b.ko.seznam.cz [10.53.18.29])
 id 4e859b28b1df22174e5a018b; Tue, 08 Sep 2020 17:50:53 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seznam.cz; s=beta;
 t=1599580253; bh=CLFav8mpL00HE9/TK0Ik1Cd9uDuV8tdKg3r9Jk5kOl8=;
 h=Received:From:To:Subject:Date:Message-Id:Mime-Version:X-Mailer:
 Content-Type;
 b=lrlGpxXiniUUO8+oSyzkZMgH4KELaa3NHoJ2PFOG5MQeQty7iYBC4W6vavM1zNP4q
 x1rEZTUOtAik1BkhW/NPuYCLik60VmU6LPc2YyEntgxgpvpzalxAXjIMIkoN6hvIzr
 CVLgzsvEcza3smQjuDuWVBG4R0P2Kk8jTiTZ5b1U=
Received: from unknown ([::ffff:77.236.218.167])
 by email.seznam.cz (szn-ebox-5.0.41) with HTTP;
 Tue, 08 Sep 2020 17:50:50 +0200 (CEST)
From: "Martin Taibr" <Taibr@HIDDEN>
To: <bug-coreutils@HIDDEN>
Subject: tail -c +N / --bytes +N manpage wrong (off by 1)
Date: Tue, 08 Sep 2020 17:50:50 +0200 (CEST)
Message-Id: <T9.tuNS.2WK8x07EZ5e.1VLwXQ@HIDDEN>
Mime-Version: 1.0 (szn-mime-2.1.6)
X-Mailer: szn-ebox-5.0.41
Content-Type: multipart/alternative;
 boundary="=_6c0a86266f79d79475ff734e=3d2284d5-62f0-5727-a332-bad047134a30_="
Received-SPF: pass client-ip=2a02:598:a::78:89; envelope-from=Taibr@HIDDEN;
 helo=mxb1.seznam.cz
X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache.
 That's all we know.
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.4 (/)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Tue, 08 Sep 2020 11:54:48 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)

--=_6c0a86266f79d79475ff734e=3d2284d5-62f0-5727-a332-bad047134a30_=
Content-Type: text/plain;
	charset=utf-8
Content-Transfer-Encoding: quoted-printable


Currently the manpage says:





-c, --bytes=3D[+]NUM

=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 output the last NUM bytes; or use -c +NUM to output starting 
with byte NUM of each file




Most (all?) hex editors number bytes from 0 so it's natural to assume tail=
 -
c +0 will print the entire file, tail -c +1 will cut off the first byte an=
d 
so on. That's not the case, tail seems to "index" bytes from 1, not 0, so =
+0
and +1 both print the entire file.




I'd suggest

1) the manpage should mention counting starts from 1 (so you need to add 1=
 
when copy pasting offsets from most other programs)


2) +0 should print a warning since its usage indicates the user likely 
thinks tail counts from 0

3) -n / --lines docs should be changed to match (though counting lines fro=
m 
1 is more common)

--=_6c0a86266f79d79475ff734e=3d2284d5-62f0-5727-a332-bad047134a30_=
Content-Type: text/html;
	charset=utf-8
Content-Transfer-Encoding: quoted-printable

<html><body><div>Currently the manpage says:<br></div><div><br></div><div>=
-c, --bytes=3D[+]NUM</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; output the last NUM bytes; or use -c +=
NUM to output starting with byte NUM of each file</div><div><br></div><div=
>Most (all?) hex editors number bytes from 0 so it's natural to assume tai=
l -c +0 will print the entire file, tail -c +1 will cut off the first byte=
 and so on. That's not the case, tail seems to "index" bytes from 1, not 0=
, so +0 and +1 both print the entire file.</div><div><br></div><div>I'd su=
ggest</div><div>1) the manpage should mention counting starts from 1 (so y=
ou need to add 1 when copy pasting offsets from most other programs)<br></=
div><div>2) +0 should print a warning since its usage indicates the user l=
ikely thinks tail counts from 0</div><div>3) -n / --lines docs should be c=
hanged to match (though counting lines from 1 is more common)<br></div></b=
ody></html>
--=_6c0a86266f79d79475ff734e=3d2284d5-62f0-5727-a332-bad047134a30_=--





Acknowledgement sent to "Martin Taibr" <Taibr@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-coreutils@HIDDEN. Full text available.
Report forwarded to bug-coreutils@HIDDEN:
bug#43282; Package coreutils. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 8 Sep 2020 16:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.