Bug 240556

Summary: Synopsis in sed(1) is wrong
Product: Documentation Reporter: Oliver Fromme <olli>
Component: Manual PagesAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Many People CC: bcr, doc
Priority: --- Keywords: patch
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Patch for usr.bin/sed/sed.1 none

Description Oliver Fromme freebsd_committer freebsd_triage 2019-09-13 11:10:03 UTC
Created attachment 207455 [details]
Patch for usr.bin/sed/sed.1

Short description:

Apparently, when the -u, -i and -I options where added to sed(1), it was forgotten to add them to both lines in the SYNOPSIS section. They were only added to the second line, although they apply to both.

Long description:

The SYNOPSIS section of the sed(1) manual page contains two distinct usage lines:

In the first usage, a separate <command> argument is present. In this case, the -e and -f options are NOT allowed.

In the second usage, one or more commands are specified using one or more -e and/or -f options. In this case, there is NO separate <command> argument.

ALL THE OTHER options (except -e and -f) can be used with BOTH usages, including the -u, -i and -I options.  This can be easily verified by looking at the source code (usr.bin/sed/main.c), or by just trying it. For example, this command works perfectly fine, but it's disallowed by the SYNOPSIS currently:

sed -i BAK s/foo/bar/g some_file

Please see the attached patch; it fixes the problem.  It applies cleanly to both head and stable/12.
Comment 1 commit-hook freebsd_committer freebsd_triage 2020-05-19 09:18:20 UTC
A commit references this bug:

Author: bcr
Date: Tue May 19 09:17:21 UTC 2020
New revision: 361248
URL: https://svnweb.freebsd.org/changeset/base/361248

Log:
  Update SYNOPSIS section to be consistent regarding -u, -i, and -I.

  Apparently, when the -u, -i and -I options where added to sed(1), it was
  forgotten to add them to both lines in the SYNOPSIS section. They were only
  added to the second line, although they apply to both.

  With the updated SYNOPSIS, it is now allowed (and consistent) to run:

  sed -i BAK s/foo/bar/g some_file

  PR:		240556
  Submitted by:	Oliver Fromme
  MFC after:	5 days

Changes:
  head/usr.bin/sed/sed.1
Comment 2 Benedict Reuschling freebsd_committer freebsd_triage 2020-05-19 09:19:00 UTC
I've committed your patch. Thanks for filing this PR.
Comment 3 commit-hook freebsd_committer freebsd_triage 2020-05-24 10:12:36 UTC
A commit references this bug:

Author: bcr
Date: Sun May 24 10:12:32 UTC 2020
New revision: 361431
URL: https://svnweb.freebsd.org/changeset/base/361431

Log:
  MFC r361248:
  Update SYNOPSIS section to be consistent regarding -u, -i, and -I.

  Apparently, when the -u, -i and -I options where added to sed(1), it was
  forgotten to add them to both lines in the SYNOPSIS section. They were only
  added to the second line, although they apply to both.

  With the updated SYNOPSIS, it is now allowed (and consistent) to run:

  sed -i BAK s/foo/bar/g some_file

  PR:		240556
  Submitted by:	Oliver Fromme
  MFC after:	5 days

Changes:
_U  stable/12/
  stable/12/usr.bin/sed/sed.1