revision: 3504109
From POSIX BRE:
The '?', '+', and '|' characters; it is implementation-defined whether "?", "+", and "|" each match the literal character '?', '+', or '|', respectively, or behave as described for the ERE special characters '?', '+', and '|', respectively (see 9.4.3 ERE Special Characters).
- Note:
- A future version of this standard may require "\?", "\+", and "\|" to behave as described for the ERE special characters '?', '+', and '|', respectively.
GNU and BSD sed’s treat \?, \+, and \| in BRE as the ERE counterparts, whereas uutils does not:
$ cargo run --quiet -- -n -e '/cats\?$/p' <<< $'cat\ncats?'
cats?
$ sed -n -e '/cats\?$/p' <<< $'cat\ncats?'
cat
$ cargo run --quiet -- -n -e '/se\+d/p' <<< $'seed\nse+d'
se+d
$ sed -n -e '/se\+d/p' <<< $'seed\nse+d'
seed
$ cargo run --quiet -- -n -e '/foo\|bar/p' <<< $'foo\nfoo|bar'
foo|bar
$ sed -n -e '/foo\|bar/p' <<< $'foo\nfoo|bar'
foo
foo|bar
POSIX does not mandate the behavior, but it would be preferable.
revision: 3504109
From POSIX BRE:
GNU and BSD sed’s treat
\?,\+, and\|in BRE as the ERE counterparts, whereas uutils does not:POSIX does not mandate the behavior, but it would be preferable.