1 #!/usr/bin/env 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=10
8 for ((a=1; a <= n ; a++)) # Double parentheses, and naked 'n'
9 do
10 if test $a = 3; then
11 continue
12 fi
13 if test $a = 6; then
14 break
15 fi
16 echo $a
17 done # A construct borrowed from ksh93.
18 ## status: 0
19 ## STDOUT:
20 1
21 2
22 4
23 5
24 ## N-I mksh status: 1
25 ## N-I mksh stdout-json: ""
26
27 ### For loop with and without semicolon
28 for ((a=1; a <= 3; a++)); do
29 echo $a
30 done # A construct borrowed from ksh93.
31 for ((a=1; a <= 3; a++)) do
32 echo $a
33 done # A construct borrowed from ksh93.
34 ## status: 0
35 ## STDOUT:
36 1
37 2
38 3
39 1
40 2
41 3
42 ## N-I mksh status: 1
43 ## N-I mksh stdout-json: ""