Subject: bin/23853: sed's "regular expressions" suck
To: None <>
From: None <>
List: netbsd-bugs
Date: 12/23/2003 06:59:46
>Number:         23853
>Category:       bin
>Synopsis:       sed's "regular expressions" suck
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Dec 23 12:15:00 UTC 2003
>Originator:     VaX#n8
>Release:        NetBSD 1.5.1

sed's "regular expressions" are downright embarassing.
There are no alternations "|", no "+", no '?', not much of anything.
The manpage makes a misleading reference to re_format(7).


$ echo foo | sed -n 's/foo/baz/p'
$ echo foo | sed -n 's/foo\|bar/baz/p'
$ echo foo | sed -n 's/foo|bar/baz/p'
$ echo foo | sed -n 's/fo+/baz/p'
$ echo foo | sed -n 's/fo?/baz/p'
$ echo foo | sed -n 's/foo?/baz/p'
$ echo foo | sed -n 's/foo\?/baz/p'

I'm guessing sed does some stuff which isn't done by the regex libraries
used by other userland tools, but someone should look into either changing
them to do what sed needs, or something.

Incidentally, I found this while trying to port Linux's "killall", from
their psmisc SRPM.  I really wish we had that command, and although I
could probably do it in a shell script, I'll try C first, unless someone
persuades me otherwise.  Their sed handles regexps just fine.