News for hackers. Stuff that matters.
Re:Edsger Dijkstra's note on starting array indices at 0 (pd... by waterhouse on Tuesday June 21, 2011 @08:23PM (#2681011)
I'll take this opportunity to bash the Unix "tail" utility. "tail -c +n" is supposed to mean "print all characters (or bytes, rather), starting at index n". Unfortunately, the implementer used 1-origin indexing, which is bad enough when I expect 0-origin. But there's also a clear alternative semantics that doesn't even use the concept of indexing: "tail -c +n" should mean "exclude the first n bytes". Both interpretations lead me to expect the following command to output "56789", but it doesn't, and I have been burned twice already by off-by-one errors due to this:

  $ echo '0123456789' | tail -c +5
  456789
Re:Edsger Dijkstra's note on starting array indices at 0 (pd... by veyron on Wednesday June 22, 2011 @01:35AM (#2681877)
I am sympathetic to your desires, but the man page clearly states the implemented behavior:

    $ tail --version | head -n 1
    tail (GNU coreutils) 8.5
    $ man tail | grep -A 2 bytes=K
       -c, --bytes=K
              output the last K bytes; alternatively,  use  -c  +K  to  output
              bytes starting with the Kth of each file
The fifth byte of '0123456789' is the byte corresponding to '4', and the manpage says it will output bytes starting with the 5th (ie 456789)