Shells in OCaml
at main 50 lines 693 B view raw
1While clauses. 2 3 $ cat > test.sh << EOF 4 > i=1 5 > 6 > while [ "\$i" -le 5 ] 7 > do 8 > echo "Iteration \$i..." 9 > i=\$((i + 1)) 10 > done 11 > 12 > EOF 13 14 $ sh test.sh 15 Iteration 1... 16 Iteration 2... 17 Iteration 3... 18 Iteration 4... 19 Iteration 5... 20 $ msh test.sh 21 Iteration 1... 22 Iteration 2... 23 Iteration 3... 24 Iteration 4... 25 Iteration 5... 26 27Also until loops. 28 29 $ cat > test.sh << EOF 30 > i=1 31 > 32 > until [ "\$i" -ge 5 ] 33 > do 34 > echo "Iteration \$i..." 35 > i=\$((i + 1)) 36 > done 37 > 38 > EOF 39 40 41 $ sh test.sh 42 Iteration 1... 43 Iteration 2... 44 Iteration 3... 45 Iteration 4... 46 $ msh test.sh 47 Iteration 1... 48 Iteration 2... 49 Iteration 3... 50 Iteration 4...