Skip to content

Commit d81181c

Browse files
committed
Enable native binary support.
Looks for native binaries in the libexec folder.
1 parent acd00b2 commit d81181c

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/main/bash/sdkman-main.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,23 @@ function sdk() {
136136
__sdkman_echo_red "Stop! $QUALIFIER is not a valid offline mode."
137137
fi
138138

139-
# Check whether the command exists as an internal function...
140-
#
141-
# NOTE Internal commands use underscores rather than hyphens,
142-
# hence the name conversion as the first step here.
143-
CONVERTED_CMD_NAME=$(echo "$COMMAND" | tr '-' '_')
144-
145139
# Store the return code of the requested command
146140
local final_rc=0
147141

148142
# Execute the requested command
149-
if [ -n "$CMD_FOUND" ]; then
143+
local native_command="${SDKMAN_DIR}/libexec/${COMMAND}"
144+
145+
# Internal commands use underscores rather than hyphens
146+
local converted_command_name=$(echo "$COMMAND" | tr '-' '_')
147+
148+
if [ -f "$native_command" ]; then
149+
# It's available as a native binary
150+
"$native_command" "$QUALIFIER" "$3" "$4"
151+
152+
elif [ -n "$CMD_FOUND" ]; then
153+
150154
# It's available as a shell function
151-
__sdk_"$CONVERTED_CMD_NAME" "$QUALIFIER" "$3" "$4"
155+
__sdk_"$converted_command_name" "$QUALIFIER" "$3" "$4"
152156
final_rc=$?
153157
fi
154158

0 commit comments

Comments
 (0)