-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample.sh
executable file
·54 lines (43 loc) · 1.3 KB
/
example.sh
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh
# Just an example of the concepts. This script will fail first run (on purpose) and complete on second run.
# use example_reset.sh to reset it.
#
# Expected output from first run:
# -------------------------------
#
# Executed just once
# Print Twice
# Print Twice
# Script will fail in next line first run, run again should skip above prints and continue from this point.
#
# Expected output from second run:
# --------------------------------
#
# Second run, will resume from last point:
# Completed test. Run example_cleanup.sh to run it again.
source ./bash-resume.sh
br_init ".br-test"
fail_first_time() {
if [ ! -f ".blah.txt" ];
then
echo "ok" > .blah.txt;
return 1;
fi
return 0
}
# This comand will only be executed once
br echo "Executed just once"
nbr blargie echo "Print Twice"
nbr blargiz echo "Print Twice"
if [ ! -f ".blah.txt" ];
then
echo "Script will fail in next line first run, run again should skip above prints and continue from this point."
else
echo "Second run, will resume from last point:"
fi
# Script should fail here, second run will proceed.
br fail_first_time
# Clear the "done test" marker
br_clear done_test
br echo "Executed just once"
nbr done_test echo "Completed test. Run example_cleanup.sh to reset the state before running it again."