1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 12:06:45 +00:00

Better maintenance and stronger

This commit is contained in:
Tw93
2025-11-19 09:54:57 +08:00
parent c018504e5f
commit 50b9a3227b
2 changed files with 51 additions and 27 deletions

View File

@@ -156,7 +156,15 @@ get_source_version() {
get_installed_version() {
local binary="$INSTALL_DIR/mole"
if [[ -x "$binary" ]]; then
"$binary" --version 2> /dev/null | awk 'NF {print $NF; exit}'
# Try running the binary first (preferred method)
local version
version=$("$binary" --version 2> /dev/null | awk 'NF {print $NF; exit}')
if [[ -n "$version" ]]; then
echo "$version"
else
# Fallback: parse VERSION from file (in case binary is broken)
sed -n 's/^VERSION="\(.*\)"$/\1/p' "$binary" | head -n1
fi
fi
}