Version: v1.36.1
Also reproducible on the master branch of the repository.
POSIX Issue 8, changed the specification of sed to require
implementations to support s/[/]// as major implementations like
NetBSD, GNU, and busybox sed have been doing.
However, busybox's implemenation is a bit different and does not seem
compatible with the POSIX Issue 8 specification unlike NetBSD and GNU's:
Command: sed 's/[\/]//'
Input: a\b/c
GNU: ab/c
NetBSD: ab/c
busybox: a\bc
GNU and NetBSD sed consider [\/] a bracket expression containing
backlash and slash; while busybox expands \/ as just /, and considers it
the same as [/], a bracket expression with only slash.
GNU and NetBSD's implementation seems to be the correct POSIX Issue 8
interpretation:
- sed description of the [2addr]s/RE/replacements/flags
Within the RE (as a sed extension to the BRE and ERE syntax) and the
replacement, the delimiter shall not terminate the RE or replacement
if it is the second character of an escape sequence (see XBD 9.1
Regular Expression Definitions ).
- sed "Regular Expressions in sed"
The delimiter character that precedes and follows the RE shall not
terminate the RE when it appears within a bracket expression, and
shall have its normal meaning in the bracket expression. For
example, the context address "\%[%]%" is equivalent to "/[%]/" , and
the command "s-[0-9]--g" is equivalent to "s/[0-9]//g".
- XDB 9.1 description of "escape sequence"
The escape character followed by any single character, which is
thereby "escaped". The escape character is a <backslash> that is
neither in a bracket expression nor itself escaped.
POSIX Issue 8 can be read online at:
* sed: https://pubs.opengroup.org/onlinepubs/9799919799/utilities/sed.html
* XDB 9.1:
https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap09.html#tag_09_01
[\/] just like [/] does not terminate the RE because / in a bracket
expression is literal; however, \/ in a bracket expression is not a
"escape sequence", therefore [\/] should not be interpreted as [/].
o/
emanuele6
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox