read -r does not protect backslashes
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
dash (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Edit: This isn't a bug in "read" - it's the way dash's "echo" handles backslashes.
Both natty and oneiric dash fail to protect backslashes when using "read -r".
natty: dash 0.5.5.1-7.2ubuntu1
oneiric: dash 0.5.5.1-7.4ubuntu1
Example bug:
$ echo '000\n999' | dash -c ' read -r f ; echo "$f" '
000
999
Other shells do it correctly:
$ echo '000\n999' | bash -c ' read -r f ; echo "$f" '
000\n999
$ echo '000\n999' | static-sh -c ' read -r f ; echo "$f" '
000\n999
This means you can't use "read" to read arbitrary lines of text.
ProblemType: Bug
DistroRelease: Ubuntu 11.04
Package: dash 0.5.5.1-7.2ubuntu1
ProcVersionSign
Uname: Linux 2.6.38-12-generic x86_64
Architecture: amd64
Date: Sat Oct 22 18:28:32 2011
InstallationMedia: Ubuntu 11.04 "Natty Narwhal" - Release amd64 (20110427.1)
SourcePackage: dash
UpgradeStatus: No upgrade log present (probably fresh install)
The backslash escape sequences are being processed by "echo", not "read". You can avoid this inconsistency by doing something like
printf "%s\n" '000\n999' | dash -c ' read -r f ; printf "%s\n" "$f" '