sh: Fix 'read' if all chars before the first IFS char are backslash-escaped.
Backslash-escaped characters did not set the flag for a non-IFS character. MFC after: 2 weeks
This commit is contained in:
parent
bf74de7eba
commit
917fdfb106
@ -174,6 +174,7 @@ readcmd(int argc __unused, char **argv __unused)
|
||||
continue;
|
||||
if (backslash) {
|
||||
backslash = 0;
|
||||
startword = 0;
|
||||
if (c != '\n')
|
||||
STPUTC(c, p);
|
||||
continue;
|
||||
|
10
tools/regression/bin/sh/builtins/read4.0
Normal file
10
tools/regression/bin/sh/builtins/read4.0
Normal file
@ -0,0 +1,10 @@
|
||||
# $FreeBSD$
|
||||
|
||||
printf '%s\n' '\a\ b c' | { read a b; printf '%s\n' "x${a}x${b}x"; }
|
||||
printf '%s\n' '\a b\ c' | { read a b; printf '%s\n' "x${a}x${b}x"; }
|
||||
printf '%s\n' '\a\:b:c' | { IFS=: read a b; printf '%s\n' "x${a}x${b}x"; }
|
||||
printf '%s\n' '\a:b\:c' | { IFS=: read a b; printf '%s\n' "x${a}x${b}x"; }
|
||||
printf '%s\n' '\\ a' | { read a b; printf '%s\n' "x${a}x${b}x"; }
|
||||
printf '%s\n' '\\:a' | { IFS=: read a b; printf '%s\n' "x${a}x${b}x"; }
|
||||
printf '%s\n' '\\\ a' | { read a b; printf '%s\n' "x${a}x${b}x"; }
|
||||
printf '%s\n' '\\\:a' | { IFS=: read a b; printf '%s\n' "x${a}x${b}x"; }
|
8
tools/regression/bin/sh/builtins/read4.0.stdout
Normal file
8
tools/regression/bin/sh/builtins/read4.0.stdout
Normal file
@ -0,0 +1,8 @@
|
||||
xa bxcx
|
||||
xaxb cx
|
||||
xa:bxcx
|
||||
xaxb:cx
|
||||
x\xax
|
||||
x\xax
|
||||
x\ axx
|
||||
x\:axx
|
Loading…
x
Reference in New Issue
Block a user