bash-style for (()) loops
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
mksh |
Opinion
|
Wishlist
|
Unassigned |
Bug Description
LTP (https:/
using the bash for (()) loops, as described in the bash manual:
```
An alternate form of the for command is also supported:
for (( expr1 ; expr2 ; expr3 )) ; do commands ; done
First, the arithmetic expression expr1 is evaluated according to the
rules described below (see Shell Arithmetic). The arithmetic
expression expr2 is then evaluated repeatedly until it evaluates to
zero. Each time expr2 evaluates to a non-zero value, commands are
executed and the arithmetic expression expr3 is evaluated. If any
expression is omitted, it behaves as if it evaluates to 1. The return
value is the exit status of the last command in commands that is
executed, or false if any of the expressions is invalid.
``` (https:/
these aren't supported by mksh (or by dash, according to
http://
do you feel like this bash extension is in scope for mksh? i might be
able to contribute an implementation (though i have a long-standing
line editing bug i should fix first), but i wanted to check first
whether this would be considered useful enough?
No.
They’re ugly enough in C, and they can easily be transformed into something portable:
for ((a; b; c)); do
blah
done
↓
(( a ))
while (( b )); do
blah
(( c ))
done
So, *really*, no. I’m translating for loops in C source into while loops as I go, even.