2 # Run z-machine interpreter, allowing the user to save their game in a
3 # directory specific to their client cert.
16 [ -n "$TLS_CLIENT_HASH" ] ||
exit 1
18 if [ -n "$SPAWN_PARAMETER" ]; then
19 sanitised
="$(tr -dc [:alnum:]_ <<< "$SPAWN_PARAMETER")"
20 gamefile
="$var/games/$sanitised"
21 if ! ( [ -n "$sanitised" ] && [ -e "$gamefile" ] ); then
22 echo "Unknown game: $sanitised"
26 echo "Choose your poison:"
29 while input
="$(readline)"; do
30 sanitised
="$(tr -dc [:alnum:]_ <<< "$input")"
31 gamefile
="$var/games/$sanitised"
32 if [ -n "$sanitised" ] && [ -e "$gamefile" ]; then
35 echo "Please enter one of the listed games"
39 echo "Starting $sanitised. Savefiles will be preserved."
42 savesdir
="$var/$TLS_CLIENT_HASH/$sanitised"
44 mkdir
-p "$savesdir" ||
exit 1
45 cd "$savesdir" ||
exit 1
47 # Impose some limits to reduce potential for abuse
52 if [[ "$(realpath "$gamefile")" =~ \.gblorb$
]]; then
53 stdbuf
-i0 -o0 cheapgit-zyg
"$gamefile"
55 # using the z-machine interpreter infuse, which has a nice stdio interface:
56 # https://gitlab.com/monkeymind/infuse
57 # Lightly hacked to improve output and to write to stderr when prompting
58 stdbuf
-i0 -o0 infuse
"$gamefile"
60 # Previous attempt: using dfrotz, but it has some problems.
61 #dfrotz -m -Z0 -R. "$gamefile"