MFC r199282: sh: Allow a newline before "in" in a for command,
as required by POSIX.
This commit is contained in:
parent
e24a574792
commit
754430692e
@ -365,7 +365,9 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : ""));
|
||||
n1 = (union node *)stalloc(sizeof (struct nfor));
|
||||
n1->type = NFOR;
|
||||
n1->nfor.var = wordtext;
|
||||
if (readtoken() == TWORD && ! quoteflag && equal(wordtext, "in")) {
|
||||
while (readtoken() == TNL)
|
||||
;
|
||||
if (lasttoken == TWORD && ! quoteflag && equal(wordtext, "in")) {
|
||||
app = ≈
|
||||
while (readtoken() == TWORD) {
|
||||
n2 = (union node *)stalloc(sizeof (struct narg));
|
||||
|
29
tools/regression/bin/sh/parser/for1.0
Normal file
29
tools/regression/bin/sh/parser/for1.0
Normal file
@ -0,0 +1,29 @@
|
||||
# $FreeBSD$
|
||||
|
||||
nl='
|
||||
'
|
||||
list=' a b c'
|
||||
for s1 in "$nl" " "; do
|
||||
for s2 in "$nl" ";"; do
|
||||
for s3 in "$nl" " "; do
|
||||
r=''
|
||||
eval "for i${s1}in ${list}${s2}do${s3}r=\"\$r \$i\"; done"
|
||||
[ "$r" = "$list" ] || exit 1
|
||||
done
|
||||
done
|
||||
done
|
||||
set -- $list
|
||||
for s2 in "$nl" " " ";"; do # s2=";" is an extension to POSIX
|
||||
for s3 in "$nl" " "; do
|
||||
r=''
|
||||
eval "for i${s2}do${s3}r=\"\$r \$i\"; done"
|
||||
[ "$r" = "$list" ] || exit 1
|
||||
done
|
||||
done
|
||||
for s1 in "$nl" " "; do
|
||||
for s2 in "$nl" ";"; do
|
||||
for s3 in "$nl" " "; do
|
||||
eval "for i${s1}in${s2}do${s3}exit 1; done"
|
||||
done
|
||||
done
|
||||
done
|
Loading…
x
Reference in New Issue
Block a user