-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathrun
More file actions
executable file
·61 lines (50 loc) · 1.47 KB
/
run
File metadata and controls
executable file
·61 lines (50 loc) · 1.47 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
#!/usr/bin/env bash
set -euo pipefail
DIST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
shell_quote() {
printf "'"
printf '%s' "$1" | sed "s/'/'\\\\''/g"
printf "'"
}
DEFAULT_MATHCODE_CLI_CMD="$(shell_quote "$DIST_DIR/mathcode") -p"
if [[ -f "$DIST_DIR/.env" ]]; then
set -a
source "$DIST_DIR/.env"
set +a
fi
is_executable_file() {
[[ -f "$1" && -x "$1" ]]
}
local_elan_tool_path() {
local tool="$1"
local elan_bin="$DIST_DIR/.local/elan/bin"
if is_executable_file "$elan_bin/$tool"; then
printf '%s\n' "$elan_bin/$tool"
return 0
fi
if is_executable_file "$elan_bin/$tool.exe"; then
printf '%s\n' "$elan_bin/$tool.exe"
return 0
fi
return 1
}
if local_elan_tool_path lean >/dev/null && local_elan_tool_path lake >/dev/null; then
export ELAN_HOME="$DIST_DIR/.local/elan"
export PATH="$DIST_DIR/.local/elan/bin:$PATH"
fi
export LEAN_PROJECT_DIR="${LEAN_PROJECT_DIR:-$DIST_DIR/lean-workspace}"
export MATHCODE_CLI_CMD="${MATHCODE_CLI_CMD:-$DEFAULT_MATHCODE_CLI_CMD}"
if [[ "${1:-}" == "webui" || "${1:-}" == "--webui" ]]; then
shift
if [[ ! -x "$DIST_DIR/mathcode-webui" ]]; then
printf 'MathCode WebUI binary is not installed here yet. Run `bash setup.sh` first.\n' >&2
exit 1
fi
export MATHCODE_WEBUI_ENV_LOADED=1
exec "$DIST_DIR/mathcode-webui" "$@"
fi
if [[ ! -x "$DIST_DIR/mathcode" ]]; then
printf 'MathCode binary is not installed here yet. Run `bash setup.sh` first.\n' >&2
exit 1
fi
exec "$DIST_DIR/mathcode" "$@"