Wrong escape character processing in dash
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
dash (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: dash
It seems dash does not handle escape characters correctly. Below is how I can trigger (what I think is) an error on Ubuntu 8.04.1.
# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_
DISTRIB_
DISTRIB_
# ls -l /bin/sh
lrwxrwxrwx 1 root root 4 2008-03-19 13:13 /bin/sh -> dash
# dpkg -l dash
ii dash 0.5.4-8ubuntu1 POSIX-compliant shell
# cat /tmp/runme
echo "printf(
# /bin/bash /tmp/runme
printf("Hello\n");
## THE PROBLEM IS HERE
# /bin/sh /tmp/runme
printf("Hello
");
I also tested this on our server running NetBSD/amd64 and I have no problems with /bin/sh there.
# uname -srm
NetBSD 4.0_STABLE amd64
# ls -l /bin/sh
-r-xr-xr-x 1 root wheel 167620 Aug 13 08:40 /bin/sh
# /usr/pkg/bin/bash /tmp/runme
printf("Hello\n");
# /bin/sh /tmp/runme
printf("Hello\n");
This also breaks the following script:
target='\1.o' z]*\).c/ '$target' /'
echo foo.c | sed -e 's/\([a-
Ubuntu /bin/dash: z]*\).c/ '$target' /'
$ target='\1.o'
$ set -x
$ echo foo.c | sed -e 's/\([a-
+ echo foo.c
+ sed -e s/\([a-z]*\).c/1.o/
1.o
Ubuntu /bin/bash: z]*\).c/ '$target' /' z]*\).c/ \1.o/'
$ target='\1.o'
$ set -x
$ echo foo.c | sed -e 's/\([a-
+ sed -e 's/\([a-
+ echo foo.c
foo.o
HP-UX /bin/sh z]*\).c/ '$target' /' z]*\).c/ \1.o/
$ target='\1.o'
$ set -x
$ echo foo.c | sed -e 's/\([a-
+ echo foo.c
+ sed -e s/\([a-
foo.o
As you can see, sed is called without the backslash in the replacement command when dash is used:
sed ... /1.o/
instead of the expected
sed ... /\1.o/