Date: Sat, 18 Nov 2023 14:24:48 -0500 (EST) From: Mouse <mo...@rodents-montreal.org> Message-ID: <202311181924.oaa10...@stone.rodents-montreal.org>
| The manual is semi-silent on it. It's not specifically described, but | -n is documented as numbering "the output lines", which I think | indicates the numbering should continue. This is a difficult one to make a decision about. In the original BSD cat, when -n (and a whole bunch of other options were added) in Oct 1980, -n worked numbering the output lines (regardless of the input file which generated them). That is, it had "lno" as a global var, which (naturally) started at 0, and was incremented when each line was written - never reset. In Mar 1989 a whole new implementation of cat replaced the original, in that one things switched to the way that are now (and remained that way until the end of the CSRG distributions) - with "line" being a local var, init'd to 0, in the function used to output a single file, so the output line numbering restarts for each input file. So, if one were to simply consider the history, neither one is automatically the intended behaviour. Whether the changed behaviour of the 1989 version was deliberate or not, I have no idea (the commit messages in the SCCS files tended to be a lot more terse than we often see today). kre