aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsabella Bosia <izaberina@gmail.com>2015-02-28 15:21:13 -0600
committerIsabella Bosia <izaberina@gmail.com>2015-02-28 15:21:13 -0600
commit6b0755085f5e020d461966489c04afc4bf26f4e0 (patch)
treea2b7e9739d1da191fb84e5815ddaae360f234c03
parent57f93c8badf944b5b3ed712e2887b3db33147efb (diff)
downloadtoybox-6b0755085f5e020d461966489c04afc4bf26f4e0.tar.gz
BSD sed uses -E instead of -r to enable ERE.
GNU sed silently supports -E as an alias for -r too.
-rw-r--r--toys/posix/sed.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/toys/posix/sed.c b/toys/posix/sed.c
index d271c509..628953c5 100644
--- a/toys/posix/sed.c
+++ b/toys/posix/sed.c
@@ -7,13 +7,13 @@
* TODO: lines > 2G could signed int wrap length counters. Not just getline()
* but N and s///
-USE_SED(NEWTOY(sed, "(version)e*f*inr", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_LOCALE))
+USE_SED(NEWTOY(sed, "(version)e*f*inrE", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_LOCALE))
config SED
bool "sed"
default y
help
- usage: sed [-inr] [-e SCRIPT]...|SCRIPT [-f SCRIPT_FILE]... [FILE...]
+ usage: sed [-inrE] [-e SCRIPT]...|SCRIPT [-f SCRIPT_FILE]... [FILE...]
Stream editor. Apply one or more editing SCRIPTs to each line of input
(from FILE or stdin) producing output (by default to stdout).
@@ -23,6 +23,7 @@ config SED
-i Edit each file in place.
-n No default output. (Use the p command to output matched lines.)
-r Use extended regular expression syntax.
+ -E Alias for -r.
-s Treat input files separately (implied by -i)
A SCRIPT is a series of one or more COMMANDs separated by newlines or
@@ -803,7 +804,7 @@ static void jewel_of_judgement(char **pline, long len)
if (!(s = unescape_delimited_string(&line, 0, 1))) goto brand;
if (!*s) corwin->rmatch[i] = 0;
else {
- xregcomp((void *)reg, s, (toys.optflags & FLAG_r)*REG_EXTENDED);
+ xregcomp((void *)reg, s, (toys.optflags & (FLAG_r | FLAG_E))*REG_EXTENDED);
corwin->rmatch[i] = reg-toybuf;
reg += sizeof(regex_t);
}
@@ -897,7 +898,7 @@ resume_s:
// allocating the space was done by extend_string() above
if (!*TT.remember) corwin->arg1 = 0;
else xregcomp((void *)(corwin->arg1 + (char *)corwin), TT.remember,
- ((toys.optflags & FLAG_r)*REG_EXTENDED)|((corwin->sflags&1)*REG_ICASE));
+ ((toys.optflags & (FLAG_r | FLAG_E))*REG_EXTENDED)|((corwin->sflags&1)*REG_ICASE));
free(TT.remember);
TT.remember = 0;
if (*line == 'w') {