-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdemo
executable file
·32 lines (31 loc) · 865 Bytes
/
demo
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
#!/bin/sh
# REPLbot demo script to show how to build a simple custom REPL.
#
# Scripts are executed as "./script run <id>" to start the REPL,
# and as "./script kill <id>" to stop it.
#
# This script does not need an explicit "kill" behavior, since it's
# a simple bash script. If you spawn other processes you may want to
# clean up after yourself though, particularly for Docker containers.
case "$1" in
run)
echo "Welcome to the demo REPL!"
while true; do
echo "Available commands:"
echo "[t] Print date & time"
echo "[q] Quit"
read command
if [ "$command" = "t" ]; then
echo "The current time is: $(date)"
elif [ "$command" = "q" ]; then
echo "Bye!"
exit
else
echo "Unknown command"
fi
done
;;
kill)
;;
*) echo "Syntax: $0 (run|kill) ID"; exit 1 ;;
esac