[Martin Maechler] > Regarding unix command line compatibility: > Note that there, 'tail' is *really* not what we want to imitate:
> "3" is the same as "-3" but different from "+3" : >I know that there is some "good" reason for the behavior of >'tail' in "Unix" > { tail -3 === tail -n 3 and > tail -3 === tail -n -3 } *** >but of course, we can't be compatible here, because in S >(and most reasonable languages :-) >"3 == +3" and "3 != -3" ! I'm not sure I understand you fully, or maybe there is a typo on the starred line above. When I speak about GNU "head" and "tail" behaviour, I'm really meaning the internal behaviour once option values have been decoded, but certainly not option representation themselves. The strange spirit of Unix designers show, where while `-' is only meant as an option introducer, by a kind of typographical pun, it is temporarily seen a negative sign when the time comes to negate a value, and this is the reason `+' was sometimes used, that is, as a humorous way to mean a minus sign in option context. So, `+' really means `-' sometimes. This is a similar kind of humour which later yielded a better "more" program to be named "less" :-). For "head" and "tail", these programs were accepting a number as first argument without requiring it to be introduced by the usual `-'. POSIX later came in and got rid of this irregularity. Moreover, within GNU, `+' option introducer was once reserved for so called "long options" and consequently unavailable for the above pun, but later freed again when the `--' convention was adopted instead of `+' for long options. Many implementations attempted to be compatible to both POSIX and pre-POSIX specifications. GNU implementation also had to cope with their own varying option standards, as well as a lot of contradictory pressure from users and within. Even nowadays, as a futile attempt to reconcile some incompatible trends that cannot be dismissed, a few environment variables can be set to alter how these tools interpret and decode the value of the dreaded option. As you may guess, confusion resulted, and those of us who followed it all never fully recovered from all the brain damage :-). [Another tiny corner of Unix where sign confusion blatantly existed was "nice", this tool meant to alter process priority.] *Once* the real value has been decoded out of the option, the current convention is as follow, given that N is a positive number: Value "head" tool "tail" tool N Show N initial lines Show N last lines -N Show all but N last lines Show all but N first lines Hoping that this clarification may be helpful in the whole thinking! :-) -- François Pinard http://pinard.progiciels-bpi.ca ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel