sed escaping question

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

 



Regarding this: (info Autoconf "Limitations of Usual Tools"):

| Portable `sed' regular expressions should use `\' only to escape
| characters in the string `$()*.0123456789[\^n{}'.  For example,
| alternation, `\|', is common but Posix does not require its
| support, so it should be avoided in portable scripts.  Solaris
| `sed' does not support alternation; e.g., `sed '/a\|b/d'' deletes
| only lines that contain the literal string `a|b'.  Similarly, `\+'
| and `\?' should be avoided.

Does this mean that `]' in a sed regex should not be escaped if it is to
match a literal `]'?

Conversely to the second half of the paragraph, can we be certain that
  sed 's|a\|b||'

does what I think it should do, namely remove a literal `a|b' from the
code, and not invoke alternation?  Or should a different delimiter be
preferred for safety?

Cheers, and thanks,
Ralf


_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux