🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: mod.std.unix
Article #471

Re: Counting from 0

#471
From: std-unix
Date: Thu, 29 Jan 1987 23:26
48 lines
2827 bytes
From: guy%gorodish@Sun.COM (Guy Harris)
Date: 29 Jan 87 07:12:50 GMT
Reply-To: guy@sun.UUCP (Guy Harris)
Organization: Sun Microsystems, Mountain View

>	While we're it, make "cmp" call the first character in a file 0.
>At least on my 4.2BSD system, cmp says the first character in a file is 1.

"cmp" hasn't changed a lot, so all the other AT&T-derived "cmp"s do
this.

>I would imagine most people only use cmp to test for equality of files, but
>I had reason to use the output of "cmp -l" the other day in a shell script
>and got burned my this.  Most likely, somebody needs to carefully go
>through every command in the book and ferret out count from 0/1 problems.

If people actually use the output of "cmp" in shell scripts, you
can't just "make 'cmp' call the first character in a file 0", since
this may break shell scripts.  You do, however, have to document
whether it calls that byte 0 or 1, and you also have to document
precisely the format of its output, so you *can* use it in shell
scripts.

>	Along those lines, what does it mean when some processor says
>"error in line 0, file foo"?  On the one hand, it makes computer sense to
>call the "first" line/character/block/whatever of a file 0.

For characters and blocks, maybe.  For lines, it may make computer
sense, but not a lot of sense otherwise.  Text editors currently call
the first line line 1, and even people exposed to C for prolonged
periods of time do so as well (probably because their text editor
does...).

>On the other hand, it is very convienent to reserve "error in line 0" to
>mean "something went wrong before I even got a chance to start reading the
>file."

Convenient for the programmer writing the code printing the error
message, maybe, but that doesn't count.  What counts in this case is
convenience to the *user*, and an error message that leaves the line
number out entirely - and even the file name, if the error doesn't
pertain to the file - is far more convenient there.

When some program says "error in line 0, file foo", it generally
means the programmer who wrote that code was too lazy to get the
error message right.

Volume-Number: Volume 9, Number 38
Technical Details
Message-ID: <7004@ut-sally.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbatt!cbosgd!ulysses!gatech!ut-sally!std-unix
References: <6882@ut-sally.UUCP> <6710@ut-sally.UUCP> <6783@ut-sally.UUCP> <6965@ut-sally.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!cbatt!cbosgd!ulysses!gatech!ut-sally!std-unix
From: std-unix@ut-sally.UUCP
Newsgroups: mod.std.unix
Subject: Re: Counting from 0
Message-ID: <7004@ut-sally.UUCP>
Date: Thu, 29-Jan-87 18:26:32 EST
Article-I.D.: ut-sally.7004
Posted: Thu Jan 29 18:26:32 1987
Date-Received: Sat, 31-Jan-87 01:53:28 EST
References: <6882@ut-sally.UUCP> <6710@ut-sally.UUCP> <6783@ut-sally.UUCP> <6965@ut-sally.UUCP>
Organization: IEEE P1003 Portable Operating System for Computer Environments Committee
Lines: 48
Approved: jsq@sally.utexas.edu