-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtutorial.sh
More file actions
executable file
·64 lines (48 loc) · 1.2 KB
/
tutorial.sh
File metadata and controls
executable file
·64 lines (48 loc) · 1.2 KB
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
55
56
57
58
59
60
61
62
63
64
#!/bin/sh
# Only Bash and Zsh are supported
. .lib/shell-compat-test.sh
# Guard against lesson re-entry
if [ -n "$_TUTR" ]; then
echo "You're already taking lesson $_TUTR, isn't one enough?"
exit 1
fi
. .lib/completed.sh
# Launch the first unfinished lesson and exit
if [ -z "$MENU" ]; then
for L in [0-9]-*.sh ; do
if ! _completed $L; then
exec $SHELL $L
fi
done
fi
# Re-exec into the user's preferred $SHELL (Bash or Zsh) for the interactive menu
# (Needed for systems like Ubuntu where /bin/sh is not powerful enough)
expr "$BASH" : ".*/bash" \| "$ZSH_NAME" : ".*zsh" >/dev/null || exec $SHELL $0 $*
if [[ -n "$ZSH_NAME" ]]; then
setopt nullglob
fi
PATH=$PWD/.lib:$PATH source progress.sh
if [[ -z "$MENU" ]]; then
cat <<-:
You are all done with the tutorial!
$(_tutr_progress)
Would you like to do a lesson over again?
:
elif [[ -f $(echo "$MENU"*) ]]; then
exec $SHELL $(echo "$MENU"*)
else
cat <<-:
$(_tutr_progress)
Which lesson would you like to run?
:
fi
select Q in [0-9]-*.sh "No thanks"; do
if [[ $Q = "No thanks" ]]; then
break
elif [[ -z $Q ]]; then
continue
else
exec $SHELL $Q
break
fi
done