[Bug report] Incorrect handling of backslashes in read -r

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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).

POSIX
<https://pubs.opengroup.org/onlinepubs/009695399/utilities/read.html> is
quite clear on this:

    -r
        Do not treat a backslash character in any special way.

-- 
Kind regards,
Peter Wu
https://lekensteyn.nl



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux