On 04/01/2019 13:20, Peter Wu wrote:
Hi,
Dash 'read' builtin with the '-r' option is not POSIX-compliant:
$ printf 'omg\\bar\\x41-\\\\-\n' > input
$ dash -c 'read -r x < input; cat input; echo "$x"'
omg\bar\x41-\\-
omar\x41-\-
The outputs are expected to be equal (which is the case with bash).
Originally found in dash 0.5.8-2.10 (Ubuntu 18.04), but also reproduced
with dash 0.5.10.2-1 (Arch Linux).
This isn't read giving the backslashes special treatment, it's echo. Use
printf "%s\n" "$x" instead and you will get the same output.
Cheers,
Harald van Dijk