Subject: bin/23853: sed's "regular expressions" suck
To: None <firstname.lastname@example.org>
From: None <email@example.com>
Date: 12/23/2003 06:59:46
>Synopsis: sed's "regular expressions" suck
>Arrival-Date: Tue Dec 23 12:15:00 UTC 2003
>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.