> On 2016/10/11 13:35, Theo de Raadt wrote:
> > > Jan Stary <[email protected]> writes:
> > > 
> > > > The diff below makes head(1) recognize `-'
> > > > as a name for the standard input,
> > > > as many other utilities do.
> > > 
> > > Makes sense to me.  The following points could be improved IMO:
> > > - using strcmp sounds cleaner than those char comparisons
> > > - I don't think the man page bits are needed.  Utilities that read from
> > >   stdin are supposed to support `-'.  I'm not sure whether the extra
> > >   example is really helpful.
> > > - should we avoid closing stdin (multiple times)?  Even though our
> > >   fclose(3) seems to cope with this, it seems that neither the
> > >   C standard nor POSIX offer such a guarantee.
> > 
> > Do standards permit that extension?
> > 
> > This is command used in scripts.  Scripts are often portable.  If one
> > operating system has an extension, but others don't, then those
> > scripts become unportable to use use of these extensions.
> > 
> > I'm not raising a new argument here, it's been raised numerous times
> > when it comes to commands commonly used in scripts.
> > 
> > So consider that first.
> 
> Standards permit it but don't require it, so it's already a mess.
> 
> "The standard input shall be used if no file operands are specified, and
> shall be used if a file operand is '-' and the implementation treats the
> '-' as meaning standard input. Otherwise, the standard input shall not
> be used. See the INPUT FILES section."
> 
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/head.html
> 
> Same for tail, of course.

Well in that case, support for "-" is probably increasing compatibility
rather than diminishing it.

Reply via email to