diff options
author | Rob Landley <rob@landley.net> | 2016-04-11 11:32:36 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2016-04-11 11:32:36 -0500 |
commit | f9b9f8a1a457f3a359c0d623fc5d0b261f458980 (patch) | |
tree | 0ed270aab3ac296de0c3f58b8174c6f53514aa42 | |
parent | cb49c305e3c78179b19d6f174ae73309544292b8 (diff) | |
download | toybox-f9b9f8a1a457f3a359c0d623fc5d0b261f458980.tar.gz |
sed -f - should read from stdin.
-rwxr-xr-x | tests/sed.test | 1 | ||||
-rw-r--r-- | toys/posix/sed.c | 3 |
2 files changed, 3 insertions, 1 deletions
diff --git a/tests/sed.test b/tests/sed.test index 7a4a8cda..822cfa37 100755 --- a/tests/sed.test +++ b/tests/sed.test @@ -127,6 +127,7 @@ testing "blank pattern repeats last pattern" \ testing "" "sed -e '1a\' -e 'huh'" "meep\nhuh\n" "" "meep" testing "" "sed -f input" "blah\nboom\n" '1a\\\nboom' 'blah' +testing "" "sed -f - input" "blah\nboom\n" 'blah' '1a\\\nboom' testing "" "sed '1a\ hello'" "merp\nhello\n" "" "merp" diff --git a/toys/posix/sed.c b/toys/posix/sed.c index e1c00bab..bafe77c4 100644 --- a/toys/posix/sed.c +++ b/toys/posix/sed.c @@ -1045,7 +1045,8 @@ void sed_main(void) for (dworkin = TT.e; dworkin; dworkin = dworkin->next) jewel_of_judgement(&dworkin->arg, strlen(dworkin->arg)); for (dworkin = TT.f; dworkin; dworkin = dworkin->next) - do_lines(xopen(dworkin->arg, O_RDONLY), dworkin->arg, jewel_of_judgement); + do_lines(strcmp(dworkin->arg, "-") ? xopen(dworkin->arg, O_RDONLY) : 0, + dworkin->arg, jewel_of_judgement); jewel_of_judgement(0, 0); dlist_terminate(TT.pattern); if (TT.nextlen) error_exit("no }"); |