@@ -466,8 +466,35 @@ private String generateCmdContent(File launcherPath, CommandSpec command) {
466466
467467 // Check for launcher implementation (highest priority, mutually exclusive)
468468 if (implementations .contains ("launcher" )) {
469- // For launcher: just execute the binary directly with all args
470- sb .append ("\" " ).append (launcherPathStr ).append ("\" %*\r \n " );
469+ // Convert relative file paths to absolute paths
470+ sb .append ("REM Convert relative file paths to absolute paths\r \n " );
471+ sb .append ("setlocal enabledelayedexpansion\r \n " );
472+ sb .append ("set CONVERTED_ARGS=\r \n " );
473+ sb .append (":loop\r \n " );
474+ sb .append ("if \" %~1\" ==\" \" goto endloop\r \n " );
475+ sb .append ("set ARG=%~1\r \n " );
476+ sb .append ("REM Check if the argument is a relative path to an existing file\r \n " );
477+ sb .append ("if exist \" %ARG%\" (\r \n " );
478+ sb .append (" REM Check if it's not already absolute (doesn't start with drive letter or UNC path)\r \n " );
479+ sb .append (" echo !ARG! | findstr /r /c:\" ^[A-Za-z]:\" /c:\" ^\\ \\ \\ \\ \" >nul\r \n " );
480+ sb .append (" if errorlevel 1 (\r \n " );
481+ sb .append (" REM It's a relative path, convert to absolute\r \n " );
482+ sb .append (" set CONVERTED_ARGS=!CONVERTED_ARGS! \" %~f1\" \r \n " );
483+ sb .append (" ) else (\r \n " );
484+ sb .append (" REM Already absolute, keep as-is\r \n " );
485+ sb .append (" set CONVERTED_ARGS=!CONVERTED_ARGS! \" %ARG%\" \r \n " );
486+ sb .append (" )\r \n " );
487+ sb .append (") else (\r \n " );
488+ sb .append (" REM Not a file path, keep as-is\r \n " );
489+ sb .append (" set CONVERTED_ARGS=!CONVERTED_ARGS! \" %ARG%\" \r \n " );
490+ sb .append (")\r \n " );
491+ sb .append ("shift\r \n " );
492+ sb .append ("goto loop\r \n " );
493+ sb .append (":endloop\r \n " );
494+ sb .append ("\r \n " );
495+
496+ // For launcher: execute the binary directly with converted args
497+ sb .append ("\" " ).append (launcherPathStr ).append ("\" %CONVERTED_ARGS%\r \n " );
471498 return sb .toString ();
472499 }
473500
@@ -530,8 +557,29 @@ private String generateShellContent(File launcherPath, CommandSpec command) {
530557
531558 // Check for launcher implementation (highest priority, mutually exclusive)
532559 if (implementations .contains ("launcher" )) {
533- // For launcher: just execute the binary directly with all args
534- sb .append ("exec \" " ).append (msysLauncherPath ).append ("\" \" $@\" \n " );
560+ // Convert relative file paths to absolute paths
561+ sb .append ("\n " );
562+ sb .append ("# Convert relative file paths to absolute paths\n " );
563+ sb .append ("CONVERTED_ARGS=\" \" \n " );
564+ sb .append ("for arg in \" $@\" ; do\n " );
565+ sb .append (" if [ -e \" $arg\" ] && [ \" $arg\" = \" ${arg#/}\" ]; then\n " );
566+ sb .append (" # It's a relative path that exists, convert to absolute\n " );
567+ sb .append (" if command -v realpath >/dev/null 2>&1; then\n " );
568+ sb .append (" arg_abs=\" $(realpath \" $arg\" )\" \n " );
569+ sb .append (" else\n " );
570+ sb .append (" # Fallback for systems without realpath\n " );
571+ sb .append (" arg_abs=\" $(cd \" $(dirname \" $arg\" )\" && pwd)/$(basename \" $arg\" )\" \n " );
572+ sb .append (" fi\n " );
573+ sb .append (" CONVERTED_ARGS=\" $CONVERTED_ARGS $arg_abs\" \n " );
574+ sb .append (" else\n " );
575+ sb .append (" # Not a file path or already absolute, keep as-is\n " );
576+ sb .append (" CONVERTED_ARGS=\" $CONVERTED_ARGS $arg\" \n " );
577+ sb .append (" fi\n " );
578+ sb .append ("done\n " );
579+ sb .append ("\n " );
580+
581+ // For launcher: execute the binary directly with converted args
582+ sb .append ("eval exec \" " ).append (msysLauncherPath ).append ("\" $CONVERTED_ARGS\n " );
535583 return sb .toString ();
536584 }
537585
0 commit comments