Command 'w' with two addresses is legal.
---
 editors/sed.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/editors/sed.c b/editors/sed.c
index 42d8e17..5695b7e 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -39,7 +39,7 @@
  * - address matching: num|/matchstr/[,num|/matchstr/|$]command
  * - commands: (p)rint, (d)elete, (s)ubstitue (with g & I flags)
  * - edit commands: (a)ppend, (i)nsert, (c)hange
- * - file commands: (r)ead
+ * - file commands: (r)ead, (w)rite
  * - backreferences in substitution expressions (\0, \1, \2...\9)
  * - grouped commands: {cmd1;cmd2}
  * - transliteration (y/source-chars/dest-chars/)
@@ -54,6 +54,8 @@
  * - Create a wrapper around regex to make libc's regex conform with sed
  *
  * Reference http://www.opengroup.org/onlinepubs/007904975/utilities/sed.html
+ *           or
+ *           http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html
  */

 //usage:#define sed_trivial_usage
@@ -510,7 +512,7 @@ static const char *parse_cmd_args(sed_cmd_t
*sed_cmd, const char *cmdstr)
        }
        /* handle file cmds: (r)ead */
        else if (idx <= IDX_w) { /* r,w */
-               if (sed_cmd->end_line || sed_cmd->end_match)
+               if ((sed_cmd->end_line || sed_cmd->end_match) && sed_cmd->cmd 
== 'r')
                        bb_error_msg_and_die("command only uses one address");
                cmdstr += parse_file_cmd(/*sed_cmd,*/ cmdstr, &sed_cmd->string);
                if (sed_cmd->cmd == 'w') {
-- 
1.7.6.4
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to