1 |
#!/bin/bash |
2 |
# |
3 |
# Constructs borrowed from ksh. Hm I didn't realize zsh also implements these! |
4 |
# mksh implements most too. |
5 |
|
6 |
### C-style for loop |
7 |
n=5 |
8 |
for ((a=1; a <= n ; a++)) # Double parentheses, and naked 'n' |
9 |
do |
10 |
echo $a |
11 |
done # A construct borrowed from ksh93. |
12 |
# stdout-json: "1\n2\n3\n4\n5\n" |
13 |
# N-I mksh stdout-json: "" |
14 |
|
15 |
### For loop with and without semicolon |
16 |
for ((a=1; a <= 3; a++)); do |
17 |
echo $a |
18 |
done # A construct borrowed from ksh93. |
19 |
for ((a=1; a <= 3; a++)) do |
20 |
echo $a |
21 |
done # A construct borrowed from ksh93. |
22 |
# stdout-json: "1\n2\n3\n1\n2\n3\n" |
23 |
# N-I mksh stdout-json: "" |
24 |
|