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 |
# status: 0 |
13 |
# stdout-json: "1\n2\n3\n4\n5\n" |
14 |
# N-I mksh status: 1 |
15 |
# N-I mksh stdout-json: "" |
16 |
|
17 |
### For loop with and without semicolon |
18 |
for ((a=1; a <= 3; a++)); do |
19 |
echo $a |
20 |
done # A construct borrowed from ksh93. |
21 |
for ((a=1; a <= 3; a++)) do |
22 |
echo $a |
23 |
done # A construct borrowed from ksh93. |
24 |
# status: 0 |
25 |
# stdout-json: "1\n2\n3\n1\n2\n3\n" |
26 |
# N-I mksh status: 1 |
27 |
# N-I mksh stdout-json: "" |
28 |
|