diff options
-rwxr-xr-x | tests/sed.test | 1 | ||||
-rw-r--r-- | toys/posix/sed.c | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/tests/sed.test b/tests/sed.test index 56d68fdb..805184e6 100755 --- a/tests/sed.test +++ b/tests/sed.test @@ -129,6 +129,7 @@ testing "" "sed '1a\ hello'" "merp\nhello\n" "" "merp" testing "" "sed -e '/x/c\' -e 'y'" 'y\n' '' 'x\n' +testing "" "sed -e 's/a[([]*b/X/'" 'X' '' 'a[(b' #echo meep | sed/sed -e '1a\' -e 'huh' #echo blah | sed/sed -f <(echo -e "1a\\\\\nboom") diff --git a/toys/posix/sed.c b/toys/posix/sed.c index 9d377cdb..a57891e5 100644 --- a/toys/posix/sed.c +++ b/toys/posix/sed.c @@ -718,7 +718,7 @@ static char *unescape_delimited_string(char **pstr, char *delim, int regex) if (!*from) return 0; // delimiter in regex character range doesn't count - if (*from == '[') { + if (!mode && *from == '[') { mode = '['; if (from[1] == ']') *(to++) = *(from++); } else if (mode && *from == ']') mode = 0; |