~emersion/mrsh

ref: f1342b124da2cf87e57f70bd8f1a9c221bca47fe mrsh/test/loop.sh -rw-r--r-- 582 bytes View raw
f1342b12Simon Ser shell/task/word: implement parameter minus operator 8 months ago
                                                                                
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
39
40
#!/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

echo "exit in infinite loop should exit immediately"
while true
do
	exit
	# https://github.com/emersion/mrsh/issues/37
	echo bad
done