View Issue Details

IDProjectCategoryView StatusLast Update
00017671003.1(2016/18)/Issue7+TC2Shell and Utilitiespublic2024-06-11 09:07
Reportermohd_akram Assigned To 
PrioritynormalSeverityEditorialTypeClarification Requested
Status ClosedResolutionAccepted 
NameMohamed Akram
Organization
User Reference
Sectionsed
Page Number3219
Line Number108018
Interp Status---
Final Accepted Text
Summary0001767: sed: clarify behavior of c (change) command
DescriptionThere's some confusion about the behavior of the sed c (change) command. Most implementations interpret it as starting the next cycle on every line that its address range matches. Meaning, any command after it in the script is not processed. Others interpret "start the next cycle" as only occurring at the end of the address range i.e. that commands following the change command are processed except on the last line of the address range.

The implementations that implement the former behavior are:

- GNU sed
- NetBSD sed
- Busybox sed
- Plan 9 sed

Those that don't are:

- FreeBSD sed
- OpenBSD sed

This has been acknowledged as a bug in FreeBSD.

This was previously corrected in NetBSD with the following explanation, referencing the V7 man page:

    sed(1) "c" command is in some sense a shorthand for "i"+"d", so,
    like "d" it should start the next cycle. This is explicitly documented
    in v7 man page:

      Delete the pattern space. With 0 or 1 address or at the end of a
      2-address range, place text on the output. Start the next cycle.

NetBSD commit: https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=45981

FreeBSD bug report: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=271817
Desired ActionChange:

Delete the pattern space. With a 0 or 1 address or at the end of a 2-address range, place text on the output and start the next cycle.

To:

Delete the pattern space. With a 0 or 1 address or at the end of a 2-address range, place text on the output. Start the next cycle.
Tagsapplied_after_i8d3, issue8

Activities

shware_systems

2023-07-27 15:42

reporter   bugnote:0006405

Ed Note: The word "text" in the Desired Action is intended to stay italicized.

Issue History

Date Modified Username Field Change
2023-07-18 17:45 mohd_akram New Issue
2023-07-18 17:45 mohd_akram Name => Mohamed Akram
2023-07-18 17:45 mohd_akram Section => sed
2023-07-18 17:45 mohd_akram Page Number => 3219
2023-07-18 17:45 mohd_akram Line Number => 108018
2023-07-27 15:40 Don Cragun Interp Status => ---
2023-07-27 15:40 Don Cragun Status New => Resolved
2023-07-27 15:40 Don Cragun Resolution Open => Accepted
2023-07-27 15:41 Don Cragun Tag Attached: issue8
2023-07-27 15:42 shware_systems Note Added: 0006405
2023-08-22 14:46 geoffclare Status Resolved => Applied
2023-08-22 14:46 geoffclare Tag Attached: applied_after_i8d3
2024-06-11 09:07 agadmin Status Applied => Closed