Skip to content

Commit 5f3c152

Browse files
committed
More robust handling of native command parameters.
1 parent bc7fd66 commit 5f3c152

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/main/bash/sdkman-main.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,27 @@ function sdk() {
139139
# Store the return code of the requested command
140140
local final_rc=0
141141

142-
# Execute the requested command
142+
# Native commands found under libexec
143143
local native_command="${SDKMAN_DIR}/libexec/${COMMAND}"
144144

145145
# Internal commands use underscores rather than hyphens
146146
local converted_command_name=$(echo "$COMMAND" | tr '-' '_')
147147

148148
if [ -f "$native_command" ]; then
149-
# It's available as a native binary
150-
"$native_command" "$QUALIFIER" "$3" "$4"
149+
# Available as native command
150+
if [ -z "$QUALIFIER" ]; then
151+
"$native_command"
152+
elif [ -z "$3" ]; then
153+
"$native_command" "$QUALIFIER"
154+
elif [ -z "$4" ]; then
155+
"$native_command" "$QUALIFIER" "$3"
156+
else
157+
"$native_command" "$QUALIFIER" "$3" "$4"
158+
fi
159+
final_rc=$?
151160

152161
elif [ -n "$CMD_FOUND" ]; then
153-
154-
# It's available as a shell function
162+
# Available as a shell function
155163
__sdk_"$converted_command_name" "$QUALIFIER" "$3" "$4"
156164
final_rc=$?
157165
fi

0 commit comments

Comments
 (0)