bug-sed
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#40239: Bug in how \cregexpc is handled


From: Enrico Maria De Angelis
Subject: bug#40239: Bug in how \cregexpc is handled
Date: Thu, 26 Mar 2020 14:18:28 +0000

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]