fix: Support for Windows with Git-Bash or MSYS Bash

- .exe executables are shims to non-extensions path
- .bat files to reshim for cmd or Powershell
- .bat execute bash script with bash built Windows
This commit is contained in:
진재연 (Jin Jae-yeon) 2024-10-24 00:29:15 +09:00 committed by 진재연
parent c5116dca60
commit 40ea0e1ce6
2 changed files with 30 additions and 1 deletions

View File

@ -78,7 +78,7 @@ write_shim_script() {
local version=$2
local executable_path=$3
if ! is_executable "$executable_path"; then
if ! is_executable "$executable_path" && ! is_executable "$executable_path.exe"; then
return 0
fi
@ -107,6 +107,32 @@ $(sort -u <"$temp_versions_path")
exec $(asdf_dir)/bin/asdf exec "${executable_name}" "\$@" # asdf_allow: ' asdf '
EOF
if [ "$OSTYPE" == "msys" ] || [ "$OSTYPE" == "win32" ]; then
cat <<EOF >"$shim_path.bat"
@ECHO OFF
$(sort -u <"$temp_versions_path" | sed -En "s/# /REM /p")
IF "%1"=="" (
GOTO NO_ARGS
) ELSE (
GOTO ARGS_EXIST
)
:NO_ARGS
bash "$HOME/.asdf/shims/${executable_name}"
GOTO EXIT
:ARGS_EXIST
SET ARGUMENTS=%*
SET ARGUMENTS=%ARGUMENTS:\\=\\\\%
bash "$HOME/.asdf/shims/${executable_name}" %ARGUMENTS%
GOTO EXIT
:EXIT
EOF
fi
rm "$temp_versions_path"
chmod +x "$shim_path"

View File

@ -618,6 +618,9 @@ plugin_executables() {
for bin_path in "${all_bin_paths[@]}"; do
for executable_file in "$bin_path"/*; do
if is_executable "$executable_file"; then
if [[ "$executable_file" == *".exe" ]]; then
executable_file=${executable_file::-4}
fi
printf "%s\n" "$executable_file"
fi
done