-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch.sh
More file actions
executable file
·41 lines (32 loc) · 1.17 KB
/
launch.sh
File metadata and controls
executable file
·41 lines (32 loc) · 1.17 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
#!/bin/bash
# Morgoth safe launch wrapper
# Defense-in-depth: restores terminal even if morgoth crashes before shutdown
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SIGIL_BIN="${SCRIPT_DIR}/../sigil-lang/parser/target/release/sigil"
MORGOTH_SRC="${SCRIPT_DIR}/src/morgoth.sg"
if [ ! -f "$SIGIL_BIN" ]; then
echo "Error: sigil binary not found at $SIGIL_BIN"
echo "Build first: cd sigil-lang/parser && cargo build --release --no-default-features --features jit,native,protocols"
exit 1
fi
if [ ! -f "$MORGOTH_SRC" ]; then
echo "Error: morgoth.sg not found at $MORGOTH_SRC"
exit 1
fi
# --hmr flag enables hot-module-reload (watches morgoth.sg for changes)
[[ " $* " == *" --hmr "* ]] && export MORGOTH_HMR_OVERRIDE=1
# Propagate source path so morgoth can resolve it regardless of cwd
export MORGOTH_SRC="$MORGOTH_SRC"
# Environment for child shells
export MORGOTH=1
export TERM=xterm-256color
export COLORTERM=truecolor
# Save terminal state
saved=$(stty -g)
cleanup() {
stty "$saved" 2>/dev/null
printf '\033[?25h\033[?1003l\033[?1006l\033[?1049l'
echo "Terminal restored."
}
trap cleanup EXIT INT TERM
exec "$SIGIL_BIN" run "$MORGOTH_SRC"