[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[minor] for/select parsing inconsistency
From: |
Martijn Dekker |
Subject: |
[minor] for/select parsing inconsistency |
Date: |
Fri, 7 Dec 2018 14:02:49 +0100 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 |
There is a minor inconsistency in grammatical parsing between 'for' and
'select' loops. Since 'select' is basically a glorified 'for', it seems
to me that they should parse the same way.
$ bash -c 'for x in; do :; done'
$ bash -c 'select x in; do :; done'
bash: -c: line 0: syntax error near unexpected token `;'
bash: -c: line 0: `select x in; do :; done'
$ bash -c 'foo=; select x in $foo; do :; done'
$
An empty iteration argument list is not accepted by 'select', unless it
results from an expansion. 'for' does accept this.
On ksh93, mksh, and zsh, both 'for' and 'select' accept a literal empty
list. On shells without 'select' (dash, yash), 'for' accepts it.
So it seems to me that 'select' on bash should change to match 'for'.
Thanks,
- M.
- [minor] for/select parsing inconsistency,
Martijn Dekker <=