Skip to content

Commit 308e55b

Browse files
committed
Fix posix script legacy asdf detection
Partially revert 098aacf
1 parent 91903e7 commit 308e55b

File tree

2 files changed

+49
-25
lines changed

2 files changed

+49
-25
lines changed

scripts/launch.fish

+28-20
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,39 @@ if test -n "$asdf"
2929
set -gx PATH "$ASDF_DATA_DIR/shims" $PATH
3030
end
3131
else
32-
echo "asdf not found" >&2
33-
echo "Looking for mise executable" >&2
34-
35-
set mise (which mise)
36-
if test -n "$mise"
37-
echo "mise executable found at $mise, activating" >&2
38-
source ( "$mise" env -s fish )
32+
# Fallback to old method for asdf version <= 0.15.x
33+
set ASDF_SH "$ASDF_DIR/asdf.fish"
34+
if test -f "$ASDF_SH"
35+
echo "Legacy pre v0.16.0 asdf install found at $ASDF_SH, sourcing" >&2
36+
# Source the old asdf.sh script for versions <= 0.15.0
37+
source "$ASDF_SH"
3938
else
40-
echo "mise not found" >&2
41-
echo "Looking for rtx executable" >&2
39+
echo "asdf not found" >&2
40+
echo "Looking for mise executable" >&2
4241

43-
set rtx (which rtx)
44-
if test -n "$rtx"
45-
echo "rtx executable found at $rtx, activating" >&2
46-
source ( "$rtx" env -s fish )
42+
set mise (which mise)
43+
if test -n "$mise"
44+
echo "mise executable found at $mise, activating" >&2
45+
source ( "$mise" env -s fish )
4746
else
48-
echo "rtx not found" >&2
49-
echo "Looking for vfox executable" >&2
47+
echo "mise not found" >&2
48+
echo "Looking for rtx executable" >&2
5049

51-
set vfox (which vfox)
52-
if test -n "$vfox"
53-
echo "vfox executable found at $vfox, activating" >&2
54-
source ( "$vfox" activate fish )
50+
set rtx (which rtx)
51+
if test -n "$rtx"
52+
echo "rtx executable found at $rtx, activating" >&2
53+
source ( "$rtx" env -s fish )
5554
else
56-
echo "vfox not found" >&2
55+
echo "rtx not found" >&2
56+
echo "Looking for vfox executable" >&2
57+
58+
set vfox (which vfox)
59+
if test -n "$vfox"
60+
echo "vfox executable found at $vfox, activating" >&2
61+
source ( "$vfox" activate fish )
62+
else
63+
echo "vfox not found" >&2
64+
end
5765
end
5866
end
5967
end

scripts/launch.sh

+21-5
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,29 @@ ASDF_DIR=${ASDF_DIR:-"${HOME}/.asdf"}
4141

4242
# Check if we have the asdf binary for version >= 0.16.0
4343
if command -v asdf >/dev/null 2>&1; then
44-
>&2 echo "asdf executable found at $(command -v asdf). Setting ASDF_DIR=${ASDF_DIR} and adding ${ASDF_DIR}/shims to PATH."
45-
# If the binary is found, set up environment for newer asdf versions
46-
export ASDF_DATA_DIR="$ASDF_DIR"
47-
export PATH="$ASDF_DATA_DIR/shims:$PATH"
44+
asdf_version=$(asdf --version 2>/dev/null)
45+
version=$(echo "$asdf_version" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
46+
major=$(echo "$version" | cut -d. -f1)
47+
minor=$(echo "$version" | cut -d. -f2)
48+
# If the version is less than 0.16.0 (i.e. major = 0 and minor < 16), use legacy method.
49+
if [ "$major" -eq 0 ] && [ "$minor" -lt 16 ]; then
50+
ASDF_SH="${ASDF_DIR}/asdf.sh"
51+
if test -f "$ASDF_SH"; then
52+
>&2 echo "Legacy pre v0.16.0 asdf install found at $ASDF_SH, sourcing"
53+
# Source the old asdf.sh script for versions <= 0.15.0
54+
. "$ASDF_SH"
55+
else
56+
>&2 echo "Legacy asdf not found at $ASDF_SH"
57+
fi
58+
else
59+
>&2 echo "asdf executable found at $(command -v asdf). Setting ASDF_DIR=${ASDF_DIR} and adding ${ASDF_DIR}/shims to PATH."
60+
# If the binary is found, set up environment for newer asdf versions
61+
export ASDF_DATA_DIR="$ASDF_DIR"
62+
export PATH="$ASDF_DATA_DIR/shims:$PATH"
63+
fi
4864
else
4965
# Fallback to old method for version <= 0.15.x
50-
ASDF_SH="${ASDF_DIR}/asdf.sh" # Path to the old shell script for version <= 0.15.x
66+
ASDF_SH="${ASDF_DIR}/asdf.sh"
5167
if test -f "$ASDF_SH"; then
5268
>&2 echo "Legacy pre v0.16.0 asdf install found at $ASDF_SH, sourcing"
5369
# Source the old asdf.sh script for versions <= 0.15.0

0 commit comments

Comments
 (0)