Sed incompatibility in SunOS 4.x

trinkle at cs.purdue.edu trinkle at cs.purdue.edu
Thu Jun 6 00:17:00 AEST 1991


     For some reason, Sun apparently changed the behavior of the "p"
flag for the "s" command.  In BSD 4.3 and derived systems, the p flag
causes the new pattern to be copied to stdout if a replacement is
made.  The SunOS 4.0.3 and 4.1.1 documentation imply this is still the
case

     (2)s/regular expression/replacement/flags
                 Substitute the replacement string for  instances
                 of  the regular expression in the pattern space.
                 Any character may be used instead of `/'.  For a
                 fuller  description see ed(1).  flags is zero or
                 more of:

                 n           n= 1 - 512.  Substitute for just the
                             nth      occurrence      of      the
                             regularexpression.

                 g           Global: substitute for all  nonover-
                             lapping  instances  of  the  regular
                             expression  rather  than  just   the
                             first one.

                 p           Print  the  pattern   space   if   a
                             replacement was made.

                 w wfilename Write: append the pattern  space  to
                             wfilename if a replacement was made.

     But in fact, it is not true.  The pattern is copied to stdout
ONLY if the -n option was specified on the command line.  I have
looked at both the 4.0.3 and 4.1.1 source code, and it is clearly
deliberate.

     I am not that familiar with the SysV version of sed.  Is this
merely a compatibility issue with SysV that is incorrectly documented,
or did Sun gratuitously decide to change a very basic utility?

Daniel Trinkle			trinkle at cs.purdue.edu
Dept. of Computer Sciences	{backbone}!purdue!trinkle
Purdue University		317-494-7844
West Lafayette, IN 47907




More information about the Comp.sys.sun mailing list