View Issue Details

IDProjectCategoryView StatusLast Update
00012311003.1(2016/18)/Issue7+TC2Shell and Utilitiespublic2024-06-11 09:08
Reporterstephane Assigned To 
PrioritynormalSeverityObjectionTypeEnhancement Request
Status ClosedResolutionAccepted As Marked 
NameStéphane Chazelas
Organization
User Reference
Sectionsed utility
Page Number3218
Line Number107963-107965
Interp StatusApproved
Final Accepted Text0001231:0004408
Summary0001231: backslash processing in text arguments
Description> The argument text shall consist of one or more lines.
> Each embedded <newline> in the text shall be preceded by
> a <backslash>. Other <backslash> characters in text shall
> be removed, and the following character shall be treated
> literally.

That means

sed 'a\
\text\
text'


for instance is *required* to output

text
text


at the end of the cycle.

That's not what several implementations including GNU and
busybox do even with POSIXLY_CORRECT in the environment, which
expand that \t to a TAB character.

That requirement is not useful and I don't expect any
application would rely on the POSIX-mandated behaviour.

There are also some variation in behaviour in:

sed 'a\
text\'


There are also some sed implementations (traditional ones like
on Solaris) that don't treat:

sed -e 'a\' -e 'text'


the same as

sed 'a\
text'


(same for sed -f a -f b, where a and b contain those two
expressions).
Desired ActionChange the text above to:

> The argument text shall consist of one or more lines.
> Each embedded <newline> (other than the one for the last line
> of the text) in the text shall be preceded by a <backslash>.
> <backslash> may itself be escaped with another <backslash>,
> the behaviour is unspecified if an unescaped <backslash> is
> immediately followed by any other character or the end of a
> sed script or script_file (including if it's the last
> character of the last line of a script_file).

Though the part about \ at the end of script or script_files
should probably be addressed elsewhere as it affects other
commands than those that take those "text argument"s.

You may also want to clarify how backslash (including
<backslash><newline>) is meant to be handled in rfile, wfile
arguments as part of that same bug.
Tagstc3-2008

Activities

geoffclare

2019-06-06 15:59

manager   bugnote:0004408

Interpretation response
------------------------
The standard states the requirements for <backslash> handling in text arguments, and conforming implementations must conform to this. However, concerns have been raised about this which are being referred to the sponsor.

Rationale:
-------------
The standard does not match some existing practice.

Notes to the Editor (not part of this interpretation):
-------------------------------------------------------
Change:
The argument text shall consist of one or more lines. Each embedded <newline> in the text shall be preceded by a <backslash>. Other <backslash> characters in text shall be removed, and the following character shall be treated literally.
to:
The argument text shall consist of one or more lines. A <backslash> in the text can be escaped with another <backslash>. The application shall ensure that each embedded <newline> (that is, those other than the terminating <newline> of the last line) in the text is preceded by an unescaped <backslash>. The behaviour is unspecified if an unescaped <backslash> is immediately followed by any character other than <backslash> or <newline>, or by the end of a script.

agadmin

2019-10-07 15:17

administrator   bugnote:0004606

Interpretation proposed: 7 October 2019

agadmin

2019-11-11 12:20

administrator   bugnote:0004650

Interpretation Approved: 11 Nov 2019

Issue History

Date Modified Username Field Change
2019-03-01 09:50 stephane New Issue
2019-03-01 09:50 stephane Name => Stéphane Chazelas
2019-03-01 09:50 stephane Section => sed utility
2019-03-01 09:50 stephane Page Number => 3218
2019-03-01 09:50 stephane Line Number => 107963-107965
2019-06-06 15:59 geoffclare Note Added: 0004408
2019-06-06 16:00 geoffclare Interp Status => Pending
2019-06-06 16:00 geoffclare Final Accepted Text => 0001231:0004408
2019-06-06 16:00 geoffclare Status New => Interpretation Required
2019-06-06 16:00 geoffclare Resolution Open => Accepted As Marked
2019-06-06 16:00 geoffclare Desired Action Updated
2019-06-06 16:00 geoffclare Tag Attached: tc3-2008
2019-10-07 15:17 agadmin Interp Status Pending => Proposed
2019-10-07 15:17 agadmin Note Added: 0004606
2019-11-11 12:20 agadmin Interp Status Proposed => Approved
2019-11-11 12:20 agadmin Note Added: 0004650
2019-12-04 11:51 geoffclare Status Interpretation Required => Applied
2024-06-11 09:08 agadmin Status Applied => Closed