edit first line of long file

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Thu Oct 25 06:40:05 AEST 1990


In article <27144 at mimsy.umd.edu> chris at mimsy.umd.edu (Chris Torek) writes:
> At least one POSIX draft has attempted to mandate that stdio should
> `reset' the input seek pointer so that (head -1; cat)<foo would produce
> an exact copy of file foo.
  [ explanation of various problems this would introduce ]
> This
> approach is doomed to failure

I agree. However, your comments do not apply to *specific* programs
(such as head)---only to the general problems of kludging this sort of
seek into stdio.

Many cloners find it fashionable to seek to the ``proper'' place before
closing fd 0. The version of head I'm using does this, so my tests
worked. My first solution is not portable to versions of head that don't
do the same, but it is not ``doomed to failure''; BSD 4.4 could easily
``doom'' it to success.

---Dan



More information about the Comp.unix.questions mailing list