Discussion:
Unifying BSD sed -E and GNU sed -r options?
(too old to reply)
Dan Kegel
2014-01-21 18:37:38 UTC
Permalink
It'd be nice to be able to use extended regexps in script
run on both bsd and gnu.

Has this issue been raised before? I couldn't find a bug tracker;
http://savannah.gnu.org/projects/sed doesn't list one.

Thanks!
- Dan
Davide Brini
2014-01-21 19:08:18 UTC
Permalink
Post by Dan Kegel
It'd be nice to be able to use extended regexps in script
run on both bsd and gnu.
Has this issue been raised before? I couldn't find a bug tracker;
http://savannah.gnu.org/projects/sed doesn't list one.
AFAIK, GNU sed has supported -E for quite some time (though it was, or perhaps it's still, undocumented).
Jose E. Marchesi
2014-01-21 19:12:09 UTC
Permalink
Hi Dan.

It'd be nice to be able to use extended regexps in script
run on both bsd and gnu.

The -E option, as a synonim of -r, has been supported by GNU sed since
at least 2006. However it was not documented until recently. See
http://lists.gnu.org/archive/html/bug-gnu-utils/2013-10/msg00010.html.
Dan Kegel
2014-01-21 19:25:14 UTC
Permalink
Right, but for now, I have to check platform before using it, e.g.

case $_os in
osx*) xregx=-E;;
*) xregx=-r;;
esac
... sed $xregx ...

I'd like it if either -r or -E worked on both gnu and bsd sed.
So this is a standardization enhancement request,
and it's possible bsd is the one that should change.
I have not yet done a search to see which of the two options
is used more in practice.
Post by Davide Brini
Post by Dan Kegel
It'd be nice to be able to use extended regexps in script
run on both bsd and gnu.
Has this issue been raised before? I couldn't find a bug tracker;
http://savannah.gnu.org/projects/sed doesn't list one.
AFAIK, GNU sed has supported -E for quite some time (though it was, or perhaps it's still, undocumented).
Davide Brini
2014-01-21 19:40:35 UTC
Permalink
Post by Dan Kegel
Right, but for now, I have to check platform before using it, e.g.
 case $_os in
 osx*) xregx=-E;;
 *) xregx=-r;;
 esac
 ... sed $xregx ...
But I'm saying exactly that you *can* use -E with GNU sed. Or maybe I don't get what you mean.
Dan Kegel
2014-01-21 19:55:39 UTC
Permalink
Oh. Duh. Problem solved. Thanks!
- Dan
Post by Davide Brini
Post by Dan Kegel
Right, but for now, I have to check platform before using it, e.g.
case $_os in
osx*) xregx=-E;;
*) xregx=-r;;
esac
... sed $xregx ...
But I'm saying exactly that you *can* use -E with GNU sed. Or maybe I don't get what you mean.
Loading...