title: What is \n\nnd supposed to do?
body: <pre><code>echo n | sed '\n\nnd'
  </code></pre>
  <p>With GNU sed, above command prints <code>n</code>. Conversely, BSD sed doesn't print anything.</p>
  <p><a href="https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html#tag_20_116_13_02" rel="nofollow noreferrer">POSIX sed spec.</a> says:</p>
  <blockquote>
  <ul>
  <li><p>In a context address, the construction <code>\cBREc</code>, where <code>c</code> is any character other than &lt;backslash&gt; or &lt;newline&gt;, shall be identical to <code>/BRE/</code>. If the character designated by <code>c</code> appears following a &lt;backslash&gt;, then it shall be considered to be that literal character, which shall not terminate the BRE. For example, in the context address <code>\xabc\xdefx</code>, the second <code>x</code> stands for itself, so that the BRE is <code>abcxdef</code>.</p>
  </li>
  <li><p>The escape sequence <code>\n</code> shall match a &lt;newline&gt; embedded in the pattern space. A literal &lt;newline&gt; shall not be used in the BRE of a context address or in the substitute function.</p>
  </li>
  </ul>
  </blockquote>
  <p>But doesn't elaborate on the contradiction introduced by these statements.</p>
  <p>My question is, which one is the correct behavior; to print <code>n</code> or nothing? Or, is the choice intentionally left to developers?</p>
  <hr />
  <p>Apparently GNU sed treats <code>\n</code> differently than other escape sequences:</p>
  <pre><code>$ echo t | sed 'st\ttt' | xxd
  00000000: 0a                                       .
  $
  $ echo n | sed 'sn\nnn' | xxd
  00000000: 6e0a                                     n.
  </code></pre>