Skip to content

Commit 3215879

Browse files
committed
Simplify native command invocation
1 parent b5ed847 commit 3215879

File tree

1 file changed

+5
-27
lines changed

1 file changed

+5
-27
lines changed

src/main/bash/sdkman-main.sh

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -141,39 +141,17 @@ function sdk() {
141141
# Native commands found under libexec
142142
local native_command="${SDKMAN_DIR}/libexec/${COMMAND}"
143143

144-
# Internal commands use underscores rather than hyphens
145-
local converted_command_name=$(echo "$COMMAND" | tr '-' '_')
146-
147144
if [ -f "$native_command" ]; then
148-
# Available as native command
149-
if [ -z "$QUALIFIER" ]; then
150-
"$native_command"
151-
elif [ -z "$3" ]; then
152-
"$native_command" "$QUALIFIER"
153-
elif [ -z "$4" ]; then
154-
"$native_command" "$QUALIFIER" "$3"
155-
elif [ -z "$5" ]; then
156-
"$native_command" "$QUALIFIER" "$3" "$4"
157-
elif [ -z "$6" ]; then
158-
"$native_command" "$QUALIFIER" "$3" "$4" "$5"
159-
elif [ -z "$7" ]; then
160-
"$native_command" "$QUALIFIER" "$3" "$4" "$5" "$6"
161-
elif [ -z "$8" ]; then
162-
"$native_command" "$QUALIFIER" "$3" "$4" "$5" "$6" "$7"
163-
elif [ -z "$9" ]; then
164-
"$native_command" "$QUALIFIER" "$3" "$4" "$5" "$6" "$7" "$8"
165-
elif [ -z "$10" ]; then
166-
"$native_command" "$QUALIFIER" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
167-
else
168-
___sdkman_help
169-
fi
170-
final_rc=$?
145+
"$native_command" "${@:2}"
171146

172147
elif [ -n "$CMD_FOUND" ]; then
148+
# Internal commands use underscores rather than hyphens
149+
local converted_command_name=$(echo "$COMMAND" | tr '-' '_')
150+
173151
# Available as a shell function
174152
__sdk_"$converted_command_name" "$QUALIFIER" "$3" "$4"
175-
final_rc=$?
176153
fi
154+
final_rc=$?
177155

178156
# Attempt upgrade after all is done
179157
if [[ "$COMMAND" != "selfupdate" && "$sdkman_selfupdate_feature" == "true" && "$sdkman_auto_update" == "true" ]]; then

0 commit comments

Comments
 (0)