head	1.5;
access;
symbols
	RELENG_8_4:1.5.0.2
	RELENG_9_1_0_RELEASE:1.4.16.1.4.2
	RELENG_9_1:1.4.16.1.0.4
	RELENG_9_1_BP:1.4.16.1
	RELENG_8_3_0_RELEASE:1.4.10.1.8.1
	RELENG_8_3:1.4.10.1.0.8
	RELENG_8_3_BP:1.4.10.1
	RELENG_9_0_0_RELEASE:1.4.16.1.2.1
	RELENG_9_0:1.4.16.1.0.2
	RELENG_9_0_BP:1.4.16.1
	RELENG_9:1.4.0.16
	RELENG_9_BP:1.4
	RELENG_7_4_0_RELEASE:1.4.14.1
	RELENG_8_2_0_RELEASE:1.4.10.1.6.1
	RELENG_7_4:1.4.0.14
	RELENG_7_4_BP:1.4
	RELENG_8_2:1.4.10.1.0.6
	RELENG_8_2_BP:1.4.10.1
	RELENG_8_1_0_RELEASE:1.4.10.1.4.1
	RELENG_8_1:1.4.10.1.0.4
	RELENG_8_1_BP:1.4.10.1
	RELENG_7_3_0_RELEASE:1.4.12.1
	RELENG_7_3:1.4.0.12
	RELENG_7_3_BP:1.4
	RELENG_8_0_0_RELEASE:1.4.10.1.2.1
	RELENG_8_0:1.4.10.1.0.2
	RELENG_8_0_BP:1.4.10.1
	RELENG_8:1.4.0.10
	RELENG_8_BP:1.4
	RELENG_7_2_0_RELEASE:1.4.8.1
	RELENG_7_2:1.4.0.8
	RELENG_7_2_BP:1.4
	RELENG_7_1_0_RELEASE:1.4.6.1
	RELENG_6_4_0_RELEASE:1.1.1.1.46.1.4.1
	RELENG_7_1:1.4.0.6
	RELENG_7_1_BP:1.4
	RELENG_6_4:1.1.1.1.46.1.0.4
	RELENG_6_4_BP:1.1.1.1.46.1
	RELENG_7_0_0_RELEASE:1.4
	RELENG_6_3_0_RELEASE:1.1.1.1.46.1
	RELENG_7_0:1.4.0.4
	RELENG_7_0_BP:1.4
	RELENG_6_3:1.1.1.1.46.1.0.2
	RELENG_6_3_BP:1.1.1.1.46.1
	RELENG_7:1.4.0.2
	RELENG_7_BP:1.4
	RELENG_6_2_0_RELEASE:1.1.1.1
	RELENG_6_2:1.1.1.1.0.54
	RELENG_6_2_BP:1.1.1.1
	RELENG_5_5_0_RELEASE:1.1.1.1
	RELENG_5_5:1.1.1.1.0.52
	RELENG_5_5_BP:1.1.1.1
	RELENG_6_1_0_RELEASE:1.1.1.1
	RELENG_6_1:1.1.1.1.0.50
	RELENG_6_1_BP:1.1.1.1
	RELENG_6_0_0_RELEASE:1.1.1.1
	RELENG_6_0:1.1.1.1.0.48
	RELENG_6_0_BP:1.1.1.1
	RELENG_6:1.1.1.1.0.46
	RELENG_6_BP:1.1.1.1
	RELENG_5_4_0_RELEASE:1.1.1.1
	RELENG_5_4:1.1.1.1.0.44
	RELENG_5_4_BP:1.1.1.1
	RELENG_4_11_0_RELEASE:1.1.1.1
	RELENG_4_11:1.1.1.1.0.42
	RELENG_4_11_BP:1.1.1.1
	RELENG_5_3_0_RELEASE:1.1.1.1
	RELENG_5_3:1.1.1.1.0.40
	RELENG_5_3_BP:1.1.1.1
	RELENG_5:1.1.1.1.0.38
	RELENG_5_BP:1.1.1.1
	RELENG_4_10_0_RELEASE:1.1.1.1
	RELENG_4_10:1.1.1.1.0.36
	RELENG_4_10_BP:1.1.1.1
	RELENG_5_2_1_RELEASE:1.1.1.1
	RELENG_5_2_0_RELEASE:1.1.1.1
	RELENG_5_2:1.1.1.1.0.34
	RELENG_5_2_BP:1.1.1.1
	RELENG_4_9_0_RELEASE:1.1.1.1
	RELENG_4_9:1.1.1.1.0.32
	RELENG_4_9_BP:1.1.1.1
	RELENG_5_1_0_RELEASE:1.1.1.1
	RELENG_5_1:1.1.1.1.0.30
	RELENG_5_1_BP:1.1.1.1
	RELENG_4_8_0_RELEASE:1.1.1.1
	RELENG_4_8:1.1.1.1.0.28
	RELENG_4_8_BP:1.1.1.1
	RELENG_5_0_0_RELEASE:1.1.1.1
	RELENG_5_0:1.1.1.1.0.26
	RELENG_5_0_BP:1.1.1.1
	RELENG_4_7_0_RELEASE:1.1.1.1
	RELENG_4_7:1.1.1.1.0.24
	RELENG_4_7_BP:1.1.1.1
	RELENG_4_6_2_RELEASE:1.1.1.1
	RELENG_4_6_1_RELEASE:1.1.1.1
	RELENG_4_6_0_RELEASE:1.1.1.1
	RELENG_4_6:1.1.1.1.0.22
	RELENG_4_6_BP:1.1.1.1
	RELENG_4_5_0_RELEASE:1.1.1.1
	RELENG_4_5:1.1.1.1.0.20
	RELENG_4_5_BP:1.1.1.1
	RELENG_4_4_0_RELEASE:1.1.1.1
	RELENG_4_4:1.1.1.1.0.18
	RELENG_4_4_BP:1.1.1.1
	RELENG_4_3_0_RELEASE:1.1.1.1
	RELENG_4_3:1.1.1.1.0.16
	RELENG_4_3_BP:1.1.1.1
	RELENG_4_2_0_RELEASE:1.1.1.1
	RELENG_4_1_1_RELEASE:1.1.1.1
	PRE_SMPNG:1.1.1.1
	RELENG_4_1_0_RELEASE:1.1.1.1
	RELENG_3_5_0_RELEASE:1.1.1.1
	RELENG_4_0_0_RELEASE:1.1.1.1
	RELENG_4:1.1.1.1.0.14
	RELENG_4_BP:1.1.1.1
	RELENG_3_4_0_RELEASE:1.1.1.1
	RELENG_3_3_0_RELEASE:1.1.1.1
	RELENG_3_2_PAO:1.1.1.1.0.12
	RELENG_3_2_PAO_BP:1.1.1.1
	RELENG_3_2_0_RELEASE:1.1.1.1
	RELENG_3_1_0_RELEASE:1.1.1.1
	RELENG_3:1.1.1.1.0.10
	RELENG_3_BP:1.1.1.1
	RELENG_2_2_8_RELEASE:1.1.1.1
	RELENG_3_0_0_RELEASE:1.1.1.1
	RELENG_2_2_7_RELEASE:1.1.1.1
	RELENG_2_2_6_RELEASE:1.1.1.1
	RELENG_2_2_5_RELEASE:1.1.1.1
	bsd_44_lite_2:1.1.1.1
	RELENG_2_2_2_RELEASE:1.1.1.1
	RELENG_2_2_1_RELEASE:1.1.1.1
	RELENG_2_2_0_RELEASE:1.1.1.1
	RELENG_2_1_7_RELEASE:1.1.1.1
	RELENG_2_1_6_1_RELEASE:1.1.1.1
	RELENG_2_1_6_RELEASE:1.1.1.1
	RELENG_2_2:1.1.1.1.0.8
	RELENG_2_2_BP:1.1.1.1
	RELENG_2_1_5_RELEASE:1.1.1.1
	RELENG_2_1_0_RELEASE:1.1.1.1
	RELENG_2_1_0:1.1.1.1.0.6
	RELENG_2_1_0_BP:1.1.1.1
	RELENG_2_0_5_RELEASE:1.1.1.1
	RELENG_2_0_5:1.1.1.1.0.4
	RELENG_2_0_5_BP:1.1.1.1
	RELENG_2_0_5_ALPHA:1.1.1.1
	RELEASE_2_0:1.1.1.1
	BETA_2_0:1.1.1.1
	ALPHA_2_0:1.1.1.1.0.2
	bsd_44_lite:1.1.1.1
	CSRG:1.1.1;
locks; strict;
comment	@# @;


1.5
date	2012.11.17.01.54.29;	author svnexp;	state Exp;
branches
	1.5.2.1;
next	1.4;

1.4
date	2007.04.06.08.43.30;	author yar;	state Exp;
branches
	1.4.2.1
	1.4.6.1
	1.4.8.1
	1.4.10.1
	1.4.12.1
	1.4.14.1
	1.4.16.1;
next	1.3;

1.3
date	2007.04.05.17.12.01;	author yar;	state Exp;
branches;
next	1.2;

1.2
date	2007.04.05.13.31.17;	author yar;	state Exp;
branches;
next	1.1;

1.1
date	94.05.27.12.32.38;	author rgrimes;	state Exp;
branches
	1.1.1.1;
next	;

1.5.2.1
date	2012.11.17.01.54.29;	author svnexp;	state dead;
branches;
next	1.5.2.2;

1.5.2.2
date	2013.03.28.13.06.08;	author svnexp;	state Exp;
branches;
next	;

1.4.2.1
date	2012.11.17.08.08.41;	author svnexp;	state Exp;
branches;
next	;

1.4.6.1
date	2008.11.25.02.59.29;	author kensmith;	state Exp;
branches;
next	;

1.4.8.1
date	2009.04.15.03.14.26;	author kensmith;	state Exp;
branches;
next	;

1.4.10.1
date	2009.08.03.08.13.06;	author kensmith;	state Exp;
branches
	1.4.10.1.2.1
	1.4.10.1.4.1
	1.4.10.1.6.1
	1.4.10.1.8.1;
next	1.4.10.2;

1.4.10.2
date	2012.11.17.10.37.19;	author svnexp;	state Exp;
branches;
next	;

1.4.10.1.2.1
date	2009.10.25.01.10.29;	author kensmith;	state Exp;
branches;
next	;

1.4.10.1.4.1
date	2010.06.14.02.09.06;	author kensmith;	state Exp;
branches;
next	;

1.4.10.1.6.1
date	2010.12.21.17.09.25;	author kensmith;	state Exp;
branches;
next	;

1.4.10.1.8.1
date	2012.03.03.06.15.13;	author kensmith;	state Exp;
branches;
next	1.4.10.1.8.2;

1.4.10.1.8.2
date	2012.11.17.08.25.51;	author svnexp;	state Exp;
branches;
next	;

1.4.12.1
date	2010.02.10.00.26.20;	author kensmith;	state Exp;
branches;
next	;

1.4.14.1
date	2010.12.21.17.10.29;	author kensmith;	state Exp;
branches;
next	1.4.14.2;

1.4.14.2
date	2012.11.17.08.17.44;	author svnexp;	state Exp;
branches;
next	;

1.4.16.1
date	2011.09.23.00.51.37;	author kensmith;	state Exp;
branches
	1.4.16.1.2.1
	1.4.16.1.4.1;
next	1.4.16.2;

1.4.16.2
date	2012.11.17.11.37.40;	author svnexp;	state Exp;
branches;
next	;

1.4.16.1.2.1
date	2011.11.11.04.20.22;	author kensmith;	state Exp;
branches;
next	1.4.16.1.2.2;

1.4.16.1.2.2
date	2012.11.17.08.37.37;	author svnexp;	state Exp;
branches;
next	;

1.4.16.1.4.1
date	2012.08.05.23.54.33;	author kensmith;	state Exp;
branches;
next	1.4.16.1.4.2;

1.4.16.1.4.2
date	2012.11.17.08.48.28;	author svnexp;	state Exp;
branches;
next	;

1.1.1.1
date	94.05.27.12.32.39;	author rgrimes;	state Exp;
branches
	1.1.1.1.46.1;
next	;

1.1.1.1.46.1
date	2007.04.19.23.29.05;	author yar;	state Exp;
branches
	1.1.1.1.46.1.4.1;
next	1.1.1.1.46.2;

1.1.1.1.46.2
date	2012.11.17.07.45.54;	author svnexp;	state Exp;
branches;
next	;

1.1.1.1.46.1.4.1
date	2008.10.02.02.57.24;	author kensmith;	state Exp;
branches;
next	;


desc
@@


1.5
log
@Switching exporter and resync
@
text
@#	@@(#)POSIX	8.1 (Berkeley) 6/6/93
# $FreeBSD: head/usr.bin/sed/POSIX 168417 2007-04-06 08:43:30Z yar $

Comments on the IEEE P1003.2 Draft 12
     Part 2: Shell and Utilities
  Section 4.55: sed - Stream editor

Diomidis Spinellis <dds@@doc.ic.ac.uk>
Keith Bostic <bostic@@cs.berkeley.edu>

In the following paragraphs, "wrong" usually means "inconsistent with
historic practice", as most of the following comments refer to
undocumented inconsistencies between the historical versions of sed and
the POSIX 1003.2 standard.  All the comments are notes taken while
implementing a POSIX-compatible version of sed, and should not be
interpreted as official opinions or criticism towards the POSIX committee.
All uses of "POSIX" refer to section 4.55, Draft 12 of POSIX 1003.2.

 1.	32V and BSD derived implementations of sed strip the text
	arguments of the a, c and i commands of their initial blanks,
	i.e.

	#!/bin/sed -f
	a\
		foo\
		\  indent\
		bar

	produces:

	foo
	  indent
	bar

	POSIX does not specify this behavior as the System V versions of
	sed do not do this stripping.  The argument against stripping is
	that it is difficult to write sed scripts that have leading blanks
	if they are stripped.  The argument for stripping is that it is
	difficult to write readable sed scripts unless indentation is allowed
	and ignored, and leading whitespace is obtainable by entering a
	backslash in front of it.  This implementation follows the BSD
	historic practice.

 2.	Historical versions of sed required that the w flag be the last
	flag to an s command as it takes an additional argument.  This
	is obvious, but not specified in POSIX.

 3.	Historical versions of sed required that whitespace follow a w
	flag to an s command.  This is not specified in POSIX.  This
	implementation permits whitespace but does not require it.

 4.	Historical versions of sed permitted any number of whitespace
	characters to follow the w command.  This is not specified in
	POSIX.  This implementation permits whitespace but does not
	require it.

 5.	The rule for the l command differs from historic practice.  Table
	2-15 includes the various ANSI C escape sequences, including \\
	for backslash.  Some historical versions of sed displayed two
	digit octal numbers, too, not three as specified by POSIX.  POSIX
	is a cleanup, and is followed by this implementation.

 6.	The POSIX specification for ! does not specify that for a single
	command the command must not contain an address specification
	whereas the command list can contain address specifications.  The
	specification for ! implies that "3!/hello/p" works, and it never
	has, historically.  Note,

		3!{
			/hello/p
		}

	does work.

 7.	POSIX does not specify what happens with consecutive ! commands
	(e.g. /foo/!!!p).  Historic implementations allow any number of
	!'s without changing the behaviour.  (It seems logical that each
	one might reverse the behaviour.)  This implementation follows
	historic practice.

 8.	Historic versions of sed permitted commands to be separated
	by semi-colons, e.g. 'sed -ne '1p;2p;3q' printed the first
	three lines of a file.  This is not specified by POSIX.
	Note, the ; command separator is not allowed for the commands
	a, c, i, w, r, :, b, t, # and at the end of a w flag in the s
	command.  This implementation follows historic practice and
	implements the ; separator.

 9.	Historic versions of sed terminated the script if EOF was reached
	during the execution of the 'n' command, i.e.:

	sed -e '
	n
	i\
	hello
	' </dev/null

	did not produce any output.  POSIX does not specify this behavior.
	This implementation follows historic practice.

10.	Deleted.

11.	Historical implementations do not output the change text of a c
	command in the case of an address range whose first line number
	is greater than the second (e.g. 3,1).  POSIX requires that the
	text be output.  Since the historic behavior doesn't seem to have
	any particular purpose, this implementation follows the POSIX
	behavior.

12.	POSIX does not specify whether address ranges are checked and
	reset if a command is not executed due to a jump.  The following
	program will behave in different ways depending on whether the
	'c' command is triggered at the third line, i.e. will the text
	be output even though line 3 of the input will never logically
	encounter that command.

	2,4b
	1,3c\
		text

	Historic implementations did not output the text in the above
	example.  Therefore it was believed that a range whose second
	address was never matched extended to the end of the input.
	However, the current practice adopted by this implementation,
	as well as by those from GNU and SUN, is as follows:  The text
	from the 'c' command still isn't output because the second address
	isn't actually matched; but the range is reset after all if its
	second address is a line number.  In the above example, only the
	first line of the input will be deleted.

13.	Historical implementations allow an output suppressing #n at the
	beginning of -e arguments as well as in a script file.  POSIX
	does not specify this.  This implementation follows historical
	practice.

14.	POSIX does not explicitly specify how sed behaves if no script is
	specified.  Since the sed Synopsis permits this form of the command,
	and the language in the Description section states that the input
	is output, it seems reasonable that it behave like the cat(1)
	command.  Historic sed implementations behave differently for "ls |
	sed", where they produce no output, and "ls | sed -e#", where they
	behave like cat.  This implementation behaves like cat in both cases.

15.	The POSIX requirement to open all w files at the beginning makes
	sed behave nonintuitively when the w commands are preceded by
	addresses or are within conditional blocks.  This implementation
	follows historic practice and POSIX, by default, and provides the
	-a option which opens the files only when they are needed.

16.	POSIX does not specify how escape sequences other than \n and \D
	(where D is the delimiter character) are to be treated.  This is
	reasonable, however, it also doesn't state that the backslash is
	to be discarded from the output regardless.  A strict reading of
	POSIX would be that "echo xyz | sed s/./\a" would display "\ayz".
	As historic sed implementations always discarded the backslash,
	this implementation does as well.

17.	POSIX specifies that an address can be "empty".  This implies
	that constructs like ",d" or "1,d" and ",5d" are allowed.  This
	is not true for historic implementations or this implementation
	of sed.

18.	The b t and : commands are documented in POSIX to ignore leading
	white space, but no mention is made of trailing white space.
	Historic implementations of sed assigned different locations to
	the labels "x" and "x ".  This is not useful, and leads to subtle
	programming errors, but it is historic practice and changing it
	could theoretically break working scripts.  This implementation
	follows historic practice.

19.	Although POSIX specifies that reading from files that do not exist
	from within the script must not terminate the script, it does not
	specify what happens if a write command fails.  Historic practice
	is to fail immediately if the file cannot be opened or written.
	This implementation follows historic practice.

20.	Historic practice is that the \n construct can be used for either
	string1 or string2 of the y command.  This is not specified by
	POSIX.  This implementation follows historic practice.

21.	Deleted.

22.	Historic implementations of sed ignore the RE delimiter characters
	within character classes.  This is not specified in POSIX.  This
	implementation follows historic practice.

23.	Historic implementations handle empty RE's in a special way: the
	empty RE is interpreted as if it were the last RE encountered,
	whether in an address or elsewhere.  POSIX does not document this
	behavior.  For example the command:

		sed -e /abc/s//XXX/

	substitutes XXX for the pattern abc.  The semantics of "the last
	RE" can be defined in two different ways:

	1. The last RE encountered when compiling (lexical/static scope).
	2. The last RE encountered while running (dynamic scope).

	While many historical implementations fail on programs depending
	on scope differences, the SunOS version exhibited dynamic scope
	behaviour.  This implementation does dynamic scoping, as this seems
	the most useful and in order to remain consistent with historical
	practice.
@


1.5.2.1
log
@file POSIX was added on branch RELENG_8_4 on 2013-03-28 13:06:08 +0000
@
text
@d1 204
@


1.5.2.2
log
@## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/248810
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
@
text
@a0 204
#	@@(#)POSIX	8.1 (Berkeley) 6/6/93
# $FreeBSD: releng/8.4/usr.bin/sed/POSIX 168417 2007-04-06 08:43:30Z yar $

Comments on the IEEE P1003.2 Draft 12
     Part 2: Shell and Utilities
  Section 4.55: sed - Stream editor

Diomidis Spinellis <dds@@doc.ic.ac.uk>
Keith Bostic <bostic@@cs.berkeley.edu>

In the following paragraphs, "wrong" usually means "inconsistent with
historic practice", as most of the following comments refer to
undocumented inconsistencies between the historical versions of sed and
the POSIX 1003.2 standard.  All the comments are notes taken while
implementing a POSIX-compatible version of sed, and should not be
interpreted as official opinions or criticism towards the POSIX committee.
All uses of "POSIX" refer to section 4.55, Draft 12 of POSIX 1003.2.

 1.	32V and BSD derived implementations of sed strip the text
	arguments of the a, c and i commands of their initial blanks,
	i.e.

	#!/bin/sed -f
	a\
		foo\
		\  indent\
		bar

	produces:

	foo
	  indent
	bar

	POSIX does not specify this behavior as the System V versions of
	sed do not do this stripping.  The argument against stripping is
	that it is difficult to write sed scripts that have leading blanks
	if they are stripped.  The argument for stripping is that it is
	difficult to write readable sed scripts unless indentation is allowed
	and ignored, and leading whitespace is obtainable by entering a
	backslash in front of it.  This implementation follows the BSD
	historic practice.

 2.	Historical versions of sed required that the w flag be the last
	flag to an s command as it takes an additional argument.  This
	is obvious, but not specified in POSIX.

 3.	Historical versions of sed required that whitespace follow a w
	flag to an s command.  This is not specified in POSIX.  This
	implementation permits whitespace but does not require it.

 4.	Historical versions of sed permitted any number of whitespace
	characters to follow the w command.  This is not specified in
	POSIX.  This implementation permits whitespace but does not
	require it.

 5.	The rule for the l command differs from historic practice.  Table
	2-15 includes the various ANSI C escape sequences, including \\
	for backslash.  Some historical versions of sed displayed two
	digit octal numbers, too, not three as specified by POSIX.  POSIX
	is a cleanup, and is followed by this implementation.

 6.	The POSIX specification for ! does not specify that for a single
	command the command must not contain an address specification
	whereas the command list can contain address specifications.  The
	specification for ! implies that "3!/hello/p" works, and it never
	has, historically.  Note,

		3!{
			/hello/p
		}

	does work.

 7.	POSIX does not specify what happens with consecutive ! commands
	(e.g. /foo/!!!p).  Historic implementations allow any number of
	!'s without changing the behaviour.  (It seems logical that each
	one might reverse the behaviour.)  This implementation follows
	historic practice.

 8.	Historic versions of sed permitted commands to be separated
	by semi-colons, e.g. 'sed -ne '1p;2p;3q' printed the first
	three lines of a file.  This is not specified by POSIX.
	Note, the ; command separator is not allowed for the commands
	a, c, i, w, r, :, b, t, # and at the end of a w flag in the s
	command.  This implementation follows historic practice and
	implements the ; separator.

 9.	Historic versions of sed terminated the script if EOF was reached
	during the execution of the 'n' command, i.e.:

	sed -e '
	n
	i\
	hello
	' </dev/null

	did not produce any output.  POSIX does not specify this behavior.
	This implementation follows historic practice.

10.	Deleted.

11.	Historical implementations do not output the change text of a c
	command in the case of an address range whose first line number
	is greater than the second (e.g. 3,1).  POSIX requires that the
	text be output.  Since the historic behavior doesn't seem to have
	any particular purpose, this implementation follows the POSIX
	behavior.

12.	POSIX does not specify whether address ranges are checked and
	reset if a command is not executed due to a jump.  The following
	program will behave in different ways depending on whether the
	'c' command is triggered at the third line, i.e. will the text
	be output even though line 3 of the input will never logically
	encounter that command.

	2,4b
	1,3c\
		text

	Historic implementations did not output the text in the above
	example.  Therefore it was believed that a range whose second
	address was never matched extended to the end of the input.
	However, the current practice adopted by this implementation,
	as well as by those from GNU and SUN, is as follows:  The text
	from the 'c' command still isn't output because the second address
	isn't actually matched; but the range is reset after all if its
	second address is a line number.  In the above example, only the
	first line of the input will be deleted.

13.	Historical implementations allow an output suppressing #n at the
	beginning of -e arguments as well as in a script file.  POSIX
	does not specify this.  This implementation follows historical
	practice.

14.	POSIX does not explicitly specify how sed behaves if no script is
	specified.  Since the sed Synopsis permits this form of the command,
	and the language in the Description section states that the input
	is output, it seems reasonable that it behave like the cat(1)
	command.  Historic sed implementations behave differently for "ls |
	sed", where they produce no output, and "ls | sed -e#", where they
	behave like cat.  This implementation behaves like cat in both cases.

15.	The POSIX requirement to open all w files at the beginning makes
	sed behave nonintuitively when the w commands are preceded by
	addresses or are within conditional blocks.  This implementation
	follows historic practice and POSIX, by default, and provides the
	-a option which opens the files only when they are needed.

16.	POSIX does not specify how escape sequences other than \n and \D
	(where D is the delimiter character) are to be treated.  This is
	reasonable, however, it also doesn't state that the backslash is
	to be discarded from the output regardless.  A strict reading of
	POSIX would be that "echo xyz | sed s/./\a" would display "\ayz".
	As historic sed implementations always discarded the backslash,
	this implementation does as well.

17.	POSIX specifies that an address can be "empty".  This implies
	that constructs like ",d" or "1,d" and ",5d" are allowed.  This
	is not true for historic implementations or this implementation
	of sed.

18.	The b t and : commands are documented in POSIX to ignore leading
	white space, but no mention is made of trailing white space.
	Historic implementations of sed assigned different locations to
	the labels "x" and "x ".  This is not useful, and leads to subtle
	programming errors, but it is historic practice and changing it
	could theoretically break working scripts.  This implementation
	follows historic practice.

19.	Although POSIX specifies that reading from files that do not exist
	from within the script must not terminate the script, it does not
	specify what happens if a write command fails.  Historic practice
	is to fail immediately if the file cannot be opened or written.
	This implementation follows historic practice.

20.	Historic practice is that the \n construct can be used for either
	string1 or string2 of the y command.  This is not specified by
	POSIX.  This implementation follows historic practice.

21.	Deleted.

22.	Historic implementations of sed ignore the RE delimiter characters
	within character classes.  This is not specified in POSIX.  This
	implementation follows historic practice.

23.	Historic implementations handle empty RE's in a special way: the
	empty RE is interpreted as if it were the last RE encountered,
	whether in an address or elsewhere.  POSIX does not document this
	behavior.  For example the command:

		sed -e /abc/s//XXX/

	substitutes XXX for the pattern abc.  The semantics of "the last
	RE" can be defined in two different ways:

	1. The last RE encountered when compiling (lexical/static scope).
	2. The last RE encountered while running (dynamic scope).

	While many historical implementations fail on programs depending
	on scope differences, the SunOS version exhibited dynamic scope
	behaviour.  This implementation does dynamic scoping, as this seems
	the most useful and in order to remain consistent with historical
	practice.
@


1.4
log
@style(9):
Use a single space before $FreeBSD$ to avoid terminal line overflow.

Pointed out by:		ru (The All-Seeing Eye)
@
text
@d2 1
a2 1
# $FreeBSD$
@


1.4.2.1
log
@Switch importer
@
text
@d2 1
a2 1
# $FreeBSD: stable/7/usr.bin/sed/POSIX 168417 2007-04-06 08:43:30Z yar $
@


1.4.16.1
log
@SVN rev 225736 on 2011-09-23 00:51:37Z by kensmith

Copy head to stable/9 as part of 9.0-RELEASE release cycle.

Approved by:	re (implicit)
@
text
@@


1.4.16.2
log
@## SVN ##
## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/ 242902
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ## r242902 | dteske | 2012-11-11 23:29:45 +0000 (Sun, 11 Nov 2012) | 10 lines
## SVN ##
## SVN ## Fix a regression introduced by SVN r211417 that saw the breakage of a feature
## SVN ## documented in usr.sbin/sysinstall/help/shortcuts.hlp (reproduced below):
## SVN ##
## SVN ## If /usr/sbin/sysinstall is linked to another filename, say
## SVN ## `/usr/local/bin/configPackages', then the basename will be used
## SVN ## as an implicit command name.
## SVN ##
## SVN ## Reviewed by:	adrian (co-mentor)
## SVN ## Approved by:	adrian (co-mentor)
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ##
@
text
@d2 1
a2 1
# $FreeBSD: stable/9/usr.bin/sed/POSIX 168417 2007-04-06 08:43:30Z yar $
@


1.4.16.1.4.1
log
@SVN rev 239080 on 2012-08-05 23:54:33Z by kensmith

Copy stable/9 to releng/9.1 as part of the 9.1-RELEASE release process.

Approved by:	re (implicit)
@
text
@@


1.4.16.1.4.2
log
@Switch importer
@
text
@d2 1
a2 1
# $FreeBSD: releng/9.1/usr.bin/sed/POSIX 168417 2007-04-06 08:43:30Z yar $
@


1.4.16.1.2.1
log
@SVN rev 227445 on 2011-11-11 04:20:22Z by kensmith

Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
cycle.

Approved by:	re (implicit)
@
text
@@


1.4.16.1.2.2
log
@Switch importer
@
text
@d2 1
a2 1
# $FreeBSD: releng/9.0/usr.bin/sed/POSIX 168417 2007-04-06 08:43:30Z yar $
@


1.4.14.1
log
@SVN rev 216618 on 2010-12-21 17:10:29Z by kensmith

Copy stable/7 to releng/7.4 in preparation for FreeBSD-7.4 release.

Approved by:	re (implicit)
@
text
@@


1.4.14.2
log
@Switch importer
@
text
@d2 1
a2 1
# $FreeBSD: releng/7.4/usr.bin/sed/POSIX 168417 2007-04-06 08:43:30Z yar $
@


1.4.12.1
log
@SVN rev 203736 on 2010-02-10 00:26:20Z by kensmith

Copy stable/7 to releng/7.3 as part of the 7.3-RELEASE process.

Approved by:	re (implicit)
@
text
@@


1.4.10.1
log
@SVN rev 196045 on 2009-08-03 08:13:06Z by kensmith

Copy head to stable/8 as part of 8.0 Release cycle.

Approved by:	re (Implicit)
@
text
@@


1.4.10.2
log
@## SVN ##
## SVN ## Exported commit - http://svnweb.freebsd.org/changeset/base/ 242909
## SVN ## CVS IS DEPRECATED: http://wiki.freebsd.org/CvsIsDeprecated
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ## r242909 | dim | 2012-11-12 07:47:19 +0000 (Mon, 12 Nov 2012) | 20 lines
## SVN ##
## SVN ## MFC r242625:
## SVN ##
## SVN ## Remove duplicate const specifiers in many drivers (I hope I got all of
## SVN ## them, please let me know if not).  Most of these are of the form:
## SVN ##
## SVN ## static const struct bzzt_type {
## SVN ##       [...list of members...]
## SVN ## } const bzzt_devs[] = {
## SVN ##       [...list of initializers...]
## SVN ## };
## SVN ##
## SVN ## The second const is unnecessary, as arrays cannot be modified anyway,
## SVN ## and if the elements are const, the whole thing is const automatically
## SVN ## (e.g. it is placed in .rodata).
## SVN ##
## SVN ## I have verified this does not change the binary output of a full kernel
## SVN ## build (except for build timestamps embedded in the object files).
## SVN ##
## SVN ## Reviewed by:	yongari, marius
## SVN ##
## SVN ## ------------------------------------------------------------------------
## SVN ##
@
text
@d2 1
a2 1
# $FreeBSD: stable/8/usr.bin/sed/POSIX 168417 2007-04-06 08:43:30Z yar $
@


1.4.10.1.8.1
log
@SVN rev 232438 on 2012-03-03 06:15:13Z by kensmith

Copy stable/8 to releng/8.3 as part of 8.3-RELEASE release cycle.

Approved by:	re (implicit)
@
text
@@


1.4.10.1.8.2
log
@Switch importer
@
text
@d2 1
a2 1
# $FreeBSD: releng/8.3/usr.bin/sed/POSIX 168417 2007-04-06 08:43:30Z yar $
@


1.4.10.1.6.1
log
@SVN rev 216617 on 2010-12-21 17:09:25Z by kensmith

Copy stable/8 to releng/8.2 in preparation for FreeBSD-8.2 release.

Approved by:	re (implicit)
@
text
@@


1.4.10.1.4.1
log
@SVN rev 209145 on 2010-06-14 02:09:06Z by kensmith

Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.

Approved by:	re (implicit)
@
text
@@


1.4.10.1.2.1
log
@SVN rev 198460 on 2009-10-25 01:10:29Z by kensmith

Copy stable/8 to releng/8.0 as part of 8.0-RELEASE release procedure.

Approved by:	re (implicit)
@
text
@@


1.4.8.1
log
@SVN rev 191087 on 2009-04-15 03:14:26Z by kensmith

Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.

Approved by:	re (implicit)
@
text
@@


1.4.6.1
log
@SVN rev 185281 on 2008-11-25 02:59:29Z by kensmith

Create releng/7.1 in preparation for moving into RC phase of 7.1 release
cycle.

Approved by:	re (implicit)
@
text
@@


1.3
log
@Add an important detail to paragraph 12: the range is reset only if its
second address is a line number.
@
text
@d2 1
a2 1
#	$FreeBSD$
@


1.2
log
@Reflect the change in rev. 1.44 of process.c.

Add $FreeBSD$ to please commit_prep.pl.
@
text
@d127 3
a129 2
	isn't actually matched; but the range is reset after all.  In the
	above example, only the first line of the input will be deleted.
@


1.1
log
@Initial revision
@
text
@d2 1
d121 8
a128 4
	Historic implementations, and this implementation, do not output
	the text in the above example.  The general rule, therefore,
	is that a range whose second address is never matched extends to
	the end of the input.
@


1.1.1.1
log
@BSD 4.4 Lite Usr.bin Sources
@
text
@@


1.1.1.1.46.1
log
@MFC 1.2-1.4:

Explain the change in sed behaviour WRT jumping over the 2nd address.
Add $FreeBSD$.

(Forgot to cvs up -j this file when doing MFC for the respective change
to the sed code.)
@
text
@a1 1
# $FreeBSD$
d120 4
a123 9
	Historic implementations did not output the text in the above
	example.  Therefore it was believed that a range whose second
	address was never matched extended to the end of the input.
	However, the current practice adopted by this implementation,
	as well as by those from GNU and SUN, is as follows:  The text
	from the 'c' command still isn't output because the second address
	isn't actually matched; but the range is reset after all if its
	second address is a line number.  In the above example, only the
	first line of the input will be deleted.
@


1.1.1.1.46.2
log
@Switch importer
@
text
@d2 1
a2 1
# $FreeBSD: stable/6/usr.bin/sed/POSIX 168880 2007-04-19 23:29:05Z yar $
@


1.1.1.1.46.1.4.1
log
@SVN rev 183531 on 2008-10-02 02:57:24Z by kensmith

Create releng/6.4 from stable/6 in preparation for 6.4-RC1.

Approved by:	re (implicit)
@
text
@@


