-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathevvm
More file actions
executable file
·66 lines (61 loc) · 2.11 KB
/
evvm
File metadata and controls
executable file
·66 lines (61 loc) · 2.11 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
65
66
#!/bin/bash
# Get the directory where the script is located
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Detect OS and architecture
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
# Detect if using musl (Alpine Linux, etc.)
IS_MUSL=false
if [[ "$OS" == "linux" ]]; then
if ldd --version 2>&1 | grep -qi musl; then
IS_MUSL=true
fi
fi
# Determine the executable
if [[ "$OS" == "linux" && "$ARCH" == "x86_64" ]]; then
if [[ "$IS_MUSL" == true ]]; then
EXECUTABLE="$SCRIPT_DIR/.executables/evvm-linux-x64-musl"
else
EXECUTABLE="$SCRIPT_DIR/.executables/evvm-linux-x64"
fi
elif [[ "$OS" == "linux" && "$ARCH" == "aarch64" ]]; then
if [[ "$IS_MUSL" == true ]]; then
EXECUTABLE="$SCRIPT_DIR/.executables/evvm-linux-arm64-musl"
else
EXECUTABLE="$SCRIPT_DIR/.executables/evvm-linux-arm64"
fi
elif [[ "$OS" == "darwin" && "$ARCH" == "x86_64" ]]; then
EXECUTABLE="$SCRIPT_DIR/.executables/evvm-darwin-x64"
elif [[ "$OS" == "darwin" && "$ARCH" == "arm64" ]]; then
EXECUTABLE="$SCRIPT_DIR/.executables/evvm-darwin-arm64"
else
echo "Unsupported platform or architecture: $OS-$ARCH"
exit 1
fi
# Execute the binary
if [[ -x "$EXECUTABLE" ]]; then
# run and capture exit status so we can handle common failure cases
"$EXECUTABLE" "$@"
status=$?
if [[ $status -ne 0 ]]; then
# exit code 126 means the kernel refused to execute the file (wrong format/arch)
if [[ $status -eq 126 ]]; then
echo "Warning: native CLI binary failed to execute (exit code 126)."
echo "This usually means the file in .executables/ is not built for your platform."
# try a fallback to Bun if available
if command -v bun >/dev/null 2>&1; then
echo "Attempting to run the CLI via Bun fallback..."
bun run cli/index.ts "$@"
exit $?
else
echo "bun is not installed. Install Bun or rebuild the binaries on the correct OS." >&2
fi
fi
exit $status
fi
else
echo "Executable not found or not executable: $EXECUTABLE"
echo "Please ensure the executable exists and has execute permissions."
echo "Try: chmod +x $EXECUTABLE"
exit 1
fi