ref: d461b314130d16f3fb866680555801ec49772edb mrsh/test/loop.sh -rw-r--r-- 499 bytes View raw
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh

echo "basic while loop"
n=asdf
echo start
while [ "$n" != "fdsa" ]; do
	echo "n: $n"
	n="fdsa"
	echo "n: $n"
done
echo stop

echo "continue in while loop should skip the iteration"
n=asdf
echo start
while [ "$n" != fdsa ]; do
	n=fdsa
	continue
	echo "this shouldn't be printed"
done
echo stop

echo "break in while loop should stop the loop"
n=asdf
echo start
while true; do
	if [ "$n" = fdsa ]; then
		break
	fi
	n=fdsa
done
echo stop

# Should exit immediately
while true
do
	exit
done