autoconf
[Top][All Lists]
Advanced

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

sed escaping question


From: Ralf Wildenhues
Subject: sed escaping question
Date: Tue, 23 May 2006 19:08:43 +0200
User-agent: Mutt/1.5.11

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




reply via email to

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