Counting from 0

std-unix at ut-sally.UUCP std-unix at ut-sally.UUCP
Wed Jan 28 13:04:18 AEST 1987


From: seismo!cmcl2!phri!roy at sally.utexas.edu (Roy Smith)
Date: Sun, 18 Jan 87 09:48:11 est
Organization: Public Health Research Inst. (NY, NY)

[ The square brackets below were apparently inserted by Roy Smith;
they were not added by the moderator.  -mod ]

> From: colonel at sunybcs.UUCP (Col. G. L. Sicherman)
> Now, that [having tail count from 1 instead of 0 is] un-Unixican.
> Characters start at 0, and perhaps blocks and lines should too.  As it
> is, if I want a shell command or expression in the argument, I usually
> have to add 1 to it to make it work.

	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.
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.

	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.  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."
-- 
Roy Smith, {allegra,cmcl2,philabs}!phri!roy
System Administrator, Public Health Research Institute
455 First Avenue, New York, NY 10016

Volume-Number: Volume 9, Number 24



More information about the Mod.std.unix mailing list