ash: allow newline after variable name in for loop
Newline is a valid delimiter between the variable name and `in` keyword in for loops. Based on commit 22e8fb4 from git://git.kernel.org/pub/scm/utils/dash/dash.git by Herbert Xu. function old new delta parse_command 1568 1563 -5 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-5) Total: -5 bytes Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
9121510dc6
commit
ab80e01cd9
@ -10913,7 +10913,7 @@ parse_command(void)
|
|||||||
n1 = stzalloc(sizeof(struct nfor));
|
n1 = stzalloc(sizeof(struct nfor));
|
||||||
n1->type = NFOR;
|
n1->type = NFOR;
|
||||||
n1->nfor.var = wordtext;
|
n1->nfor.var = wordtext;
|
||||||
checkkwd = CHKKWD | CHKALIAS;
|
checkkwd = CHKNL | CHKKWD | CHKALIAS;
|
||||||
if (readtoken() == TIN) {
|
if (readtoken() == TIN) {
|
||||||
app = ≈
|
app = ≈
|
||||||
while (readtoken() == TWORD) {
|
while (readtoken() == TWORD) {
|
||||||
@ -10940,7 +10940,7 @@ parse_command(void)
|
|||||||
* Newline or semicolon here is optional (but note
|
* Newline or semicolon here is optional (but note
|
||||||
* that the original Bourne shell only allowed NL).
|
* that the original Bourne shell only allowed NL).
|
||||||
*/
|
*/
|
||||||
if (lasttoken != TNL && lasttoken != TSEMI)
|
if (lasttoken != TSEMI)
|
||||||
tokpushback = 1;
|
tokpushback = 1;
|
||||||
}
|
}
|
||||||
checkkwd = CHKNL | CHKKWD | CHKALIAS;
|
checkkwd = CHKNL | CHKKWD | CHKALIAS;
|
||||||
|
1
shell/ash_test/ash-misc/for.right
Normal file
1
shell/ash_test/ash-misc/for.right
Normal file
@ -0,0 +1 @@
|
|||||||
|
OK
|
5
shell/ash_test/ash-misc/for.tests
Executable file
5
shell/ash_test/ash-misc/for.tests
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
for i
|
||||||
|
in OK
|
||||||
|
do
|
||||||
|
echo $i
|
||||||
|
done
|
Loading…
x
Reference in New Issue
Block a user