diff --git a/commands/use.go b/commands/use.go index 36b8033..703d2f8 100644 --- a/commands/use.go +++ b/commands/use.go @@ -124,12 +124,14 @@ func Use(args []string) { versionPath := filepath.Join(versionFolderPath, "php.exe") versionPathCGI := filepath.Join(versionFolderPath, "php-cgi.exe") composerPath := filepath.Join(versionFolderPath, "composer", "composer.phar") + envPHPFolder := "PHP_FOLDER=" + versionFolderPath // create bat script for php batCommand := "@echo off \n" - batCommand = batCommand + "set filepath=\"" + versionPath + "\"\n" - batCommand = batCommand + "set arguments=%*\n" - batCommand = batCommand + "%filepath% %arguments%\n" + batCommand += "set " + envPHPFolder + "\n" + batCommand += "set filepath=\"" + versionPath + "\"\n" + batCommand += "set arguments=%*\n" + batCommand += "%filepath% %arguments%\n" err = os.WriteFile(batPath, []byte(batCommand), 0755) @@ -139,8 +141,8 @@ func Use(args []string) { // create sh script for php shCommand := "#!/bin/bash\n" - shCommand = shCommand + "filepath=\"" + versionPath + "\"\n" - shCommand = shCommand + "\"$filepath\" \"$@\"" + shCommand += "filepath=\"" + versionPath + "\"\n" + shCommand += envPHPFolder + " \"$filepath\" \"$@\"" err = os.WriteFile(shPath, []byte(shCommand), 0755) @@ -150,9 +152,10 @@ func Use(args []string) { // create bat script for php-cgi batCommandCGI := "@echo off \n" - batCommandCGI = batCommandCGI + "set filepath=\"" + versionPathCGI + "\"\n" - batCommandCGI = batCommandCGI + "set arguments=%*\n" - batCommandCGI = batCommandCGI + "%filepath% %arguments%\n" + batCommandCGI += "set " + envPHPFolder + "\n" + batCommandCGI += "set filepath=\"" + versionPathCGI + "\"\n" + batCommandCGI += "set arguments=%*\n" + batCommandCGI += "%filepath% %arguments%\n" err = os.WriteFile(batPathCGI, []byte(batCommandCGI), 0755) @@ -162,8 +165,8 @@ func Use(args []string) { // create sh script for php-cgi shCommandCGI := "#!/bin/bash\n" - shCommandCGI = shCommandCGI + "filepath=\"" + versionPathCGI + "\"\n" - shCommandCGI = shCommandCGI + "\"$filepath\" \"$@\"" + shCommandCGI += "filepath=\"" + versionPathCGI + "\"\n" + shCommandCGI += envPHPFolder + " \"$filepath\" \"$@\"" err = os.WriteFile(shPathCGI, []byte(shCommandCGI), 0755)