GNU bug report logs - #40239
Bug in how \cregexpc is handled

Previous Next

Package: sed;

Reported by: Enrico Maria De Angelis <enricomaria.dean6elis <at> gmail.com>

Date: Thu, 26 Mar 2020 15:30:01 UTC

Severity: normal

Tags: confirmed

Merged with 40242

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


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

From: Enrico Maria De Angelis <enricomaria.dean6elis <at> gmail.com>
To: bug-sed <at> gnu.org
Subject: Bug in how \cregexpc is handled
Date: Thu, 26 Mar 2020 14:18:28 +0000
[Message part 1 (text/plain, inline)]
To whom it may concern,

From man sed, I read:
       \cregexpc
              Match lines matching the regular expression regexp.  The c
may be any character.
On the one hand

   - sed '\cncd' <<< n correctly shows empty output, since it's the same as sed
   '/n/d' <<< n based on the description above;
   - sed '\c\ccd' <<< c correctly shows an empty output too, but in this
   case the letter needed to be escaped for obvious reasons.

 On the other hand:

   - sed '\n\nnd' <<< n results in an output equal to the single character n,
   revealing that the backslash is having a double effect:
      1. it prevents the following n from closing the opening \n.
      2. it interprets the n as a newline instead of the literal letter n;
      this is confirmed by executing echo -e 'a\na' | sed -n 'N;\n\nnp'.

The is means that using n in \nregexpn prevevents the use of the literal n
in the regexp.

The issue has come to light in this StackOverflow
<https://stackoverflow.com/questions/60853746/what-is-n-nnd-supposed-to-do>
question.

Kind regards,
Enrico Maria De Angelis
[Message part 2 (text/html, inline)]

This bug report was last modified 2 years and 294 days ago.

Previous Next


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