GNU bug report logs - #36129
Error in sed manual

Previous Next

Package: sed;

Reported by: Gavin Rebeiro <gavin.rebeiro1 <at> googlemail.com>

Date: Fri, 7 Jun 2019 18:14:01 UTC

Severity: normal

Tags: notabug

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 36129 in the body.
You can then email your comments to 36129 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-sed <at> gnu.org:
bug#36129; Package sed. (Fri, 07 Jun 2019 18:14:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Gavin Rebeiro <gavin.rebeiro1 <at> googlemail.com>:
New bug report received and forwarded. Copy sent to bug-sed <at> gnu.org. (Fri, 07 Jun 2019 18:14:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Gavin Rebeiro <gavin.rebeiro1 <at> googlemail.com>
To: bug-sed <at> gnu.org
Subject: Error in sed manual
Date: Fri, 7 Jun 2019 19:10:12 +0100
[Message part 1 (text/plain, inline)]
Hi,
In section 3.3 (The s Command), we are told that both upper-case and
lower-case `i' match provided regular expressions in a case-insensitive
manner. However, in section 4.3 (selecting lines by text matching), we are
told that lower-case `i' is reserved for the insert command.

The lower-case `i' needs to be removed from section 3.3.

Best wishes,
Gavin Rebeiro
[Message part 2 (text/html, inline)]

Information forwarded to bug-sed <at> gnu.org:
bug#36129; Package sed. (Sat, 08 Jun 2019 01:51:02 GMT) Full text and rfc822 format available.

Message #8 received at 36129 <at> debbugs.gnu.org (full text, mbox):

From: Assaf Gordon <assafgordon <at> gmail.com>
To: Gavin Rebeiro <gavin.rebeiro1 <at> googlemail.com>
Cc: 36129 <at> debbugs.gnu.org
Subject: Re: bug#36129: Error in sed manual
Date: Fri, 7 Jun 2019 19:50:51 -0600
tag 36094 notabug
close 36094
stop

Hello,

On Fri, Jun 07, 2019 at 07:10:12PM +0100, Gavin Rebeiro wrote:
> In section 3.3 (The s Command), we are told that both upper-case and
> lower-case `i' match provided regular expressions in a case-insensitive
> manner. However, in section 4.3 (selecting lines by text matching), we are
> told that lower-case `i' is reserved for the insert command.
> 
> The lower-case `i' needs to be removed from section 3.3.

This is conflating three different uses of "i".

Section 3.3 refers to flags to the 's' command, i.e. the letters
appearing after the third slash (like "g"):

     s/foo/bar/i
     s/foo/bar/I
     s/foo/bar/ig

In this case, both "i" and "I" affect the behaviour of the s/// command,
allowing case-insensitive regex match for the substitution (that is, "foo"
and "FOO" and "FoO" etc. will match and will be substituted with "bar").


Section 4.3 refers to flags to regular-expression addresses - a way to
select input lines based on content, before executing any command on
them. Here, only upper-case "I" makes the match case-insensitive:

    /foo/d
    /foo/Id

In the first example, lines containing lower-case 'foo' will be deleted
(due to regex matching, followed by the 'd' command).
In the second example, the upper-case 'I' tells sed to match
case-insensitively, meaning lines with "FOO" and "FoO" will also be
deleted. Because there is no "I" command, sed knows the "I" is part
of the address regex specification.

The comment in the manual says this:

    "In many other programming languages, a lower case i is used for
     case-insensitive regular expression matching. However, in sed the i is
     used for the insert command (see insert command)."

And what it means is that if we wrote the following command:

    /foo/id

sed will actaully interpret it as:
1. /foo/ - match lines with "foo"
2. "i" - the insert command (i.e. insert text before the matching line)
3. "d" - the text to insert.

Result:

    $ printf "%s\n" foo bar | sed '/foo/id'
    d
    foo
    bar

Therefore to allow case-insensitive address-matches, sed has to choose
a letter that isn't used for other commands - hence upper-case "I".

Hope this explains the issue.
I'm closing it as "not a bug", but discussion can continue by replying
to this thread.

regards,
 - assaf







Added tag(s) notabug. Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Sat, 29 Jun 2019 08:40:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 36129 <at> debbugs.gnu.org and Gavin Rebeiro <gavin.rebeiro1 <at> googlemail.com> Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Sat, 29 Jun 2019 08:40:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 27 Jul 2019 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 273 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.