NetBSD-Bugs archive

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

bin/56972: sh: read builtin mishandles backslash in input

>Number:         56972
>Category:       bin
>Synopsis:       sh: read builtin mishandles backslash in input
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 18 23:00:00 +0000 2022
>Originator:     Valery Ushakov
>Release:        8-STABLE
NetBSD pony 8.1_STABLE NetBSD 8.1_STABLE (GENERIC) #0: Sat Jun 15 07:30:17 MSK 2019  uwe@sampo:/home/uwe/work/netbsd/build8/obj/macppc/sys/arch/macppc/compile/GENERIC macppc

Documentation for the read builtin says that

  By default, unless the -r option is specified, the backslash "\"
  acts as an escape character, causing the following character to be
  treated literally.  If a backslash is followed by a newline, the
  backslash and the newline will be deleted.

However a backslash in the input supplied to read is misinterpreted.

I tested this on both current and 8-stable.

bash$ read x y; echo "=$x=" "=$y="
\  y
= = =y=

$ read x y; echo "=$x=" "=$y="
\  y
= y= ==


Home | Main Index | Thread Index | Old Index