Hi,

I found bug in busybox 1.5.0 and latest in the repository.
Sed can't handle escaped newline in script file.

For example:
--------------------
% echo "s/foo/bar\\\nbar/g" > script

% cat script
s/foo/bar\
bar/g

% echo "foofoo" | ./busybox sed -f script
sed: can't find label for jump to 'ar/'
Exit 1
--------------------

The second line in the script file is treated as another command line.

In old busybox 1.4.2, the trial will success.

--------------------
% echo "foofoo" | ./busybox sed -f script
bar
barbar
bar
--------------------

The patch below can resolve the problem.

For 1.5.0 and latest(Rev.18251) busybox/editors/sed.c:
----------------------------------------
--- editors/sed.c.org   2007-04-12 10:32:01.000000000 +0900
+++ editors/sed.c       2007-04-12 10:36:07.000000000 +0900
@@ -483,6 +483,7 @@
                char *tp = xasprintf("%s\n%s", G.add_cmd_line, cmdstr);
                free(G.add_cmd_line);
                G.add_cmd_line = tp;
+               cmdstr = tp;
        }
 
        /* If this line ends with backslash, request next line. */
----------------------------------------

This patch works same as the busybox 1.4.2 behavior.

Best regards,
Kazuo TAKADA
_______________________________________________
busybox mailing list
[EMAIL PROTECTED]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to