From 4a0af31cae0ba075cfe195c0b13d27d8c737adcc Mon Sep 17 00:00:00 2001 From: Valerio Riva Date: Thu, 19 Dec 2024 11:15:58 +0100 Subject: [PATCH 1/3] injecting PHPRC environment var in bat / sh files --- commands/use.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/commands/use.go b/commands/use.go index 40beba8..b9f81cf 100644 --- a/commands/use.go +++ b/commands/use.go @@ -111,12 +111,14 @@ func Use(args []string) { versionFolderPath := filepath.Join(homeDir, ".pvm", "versions", selectedVersion.folder.Name()) versionPath := filepath.Join(versionFolderPath, "php.exe") versionPathCGI := filepath.Join(versionFolderPath, "php-cgi.exe") + envPHPRC := "PHPRC=" + 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 " + envPHPRC + "\n" + batCommand += "set filepath=\"" + versionPath + "\"\n" + batCommand += "set arguments=%*\n" + batCommand += "%filepath% %arguments%\n" err = os.WriteFile(batPath, []byte(batCommand), 0755) @@ -126,8 +128,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 += envPHPRC + " \"$filepath\" \"$@\"" err = os.WriteFile(shPath, []byte(shCommand), 0755) @@ -137,9 +139,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 " + envPHPRC + "\n" + batCommandCGI += "set filepath=\"" + versionPathCGI + "\"\n" + batCommandCGI += "set arguments=%*\n" + batCommandCGI += "%filepath% %arguments%\n" err = os.WriteFile(batPathCGI, []byte(batCommandCGI), 0755) @@ -149,8 +152,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 += envPHPRC + " \"$filepath\" \"$@\"" err = os.WriteFile(shPathCGI, []byte(shCommandCGI), 0755) From c9998bb31c429c17210ed71f0e87341e59d7e30e Mon Sep 17 00:00:00 2001 From: Valerio Riva Date: Thu, 19 Dec 2024 11:30:25 +0100 Subject: [PATCH 2/3] var renamed --- commands/use.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/commands/use.go b/commands/use.go index b9f81cf..f7db2df 100644 --- a/commands/use.go +++ b/commands/use.go @@ -111,11 +111,11 @@ func Use(args []string) { versionFolderPath := filepath.Join(homeDir, ".pvm", "versions", selectedVersion.folder.Name()) versionPath := filepath.Join(versionFolderPath, "php.exe") versionPathCGI := filepath.Join(versionFolderPath, "php-cgi.exe") - envPHPRC := "PHPRC=" + versionFolderPath + envPHPFolder := "PHP_FOLDER=" + versionFolderPath // create bat script for php batCommand := "@echo off \n" - batCommand += "set " + envPHPRC + "\n" + batCommand += "set " + envPHPFolder + "\n" batCommand += "set filepath=\"" + versionPath + "\"\n" batCommand += "set arguments=%*\n" batCommand += "%filepath% %arguments%\n" @@ -129,7 +129,7 @@ func Use(args []string) { // create sh script for php shCommand := "#!/bin/bash\n" shCommand += "filepath=\"" + versionPath + "\"\n" - shCommand += envPHPRC + " \"$filepath\" \"$@\"" + shCommand += envPHPFolder + " \"$filepath\" \"$@\"" err = os.WriteFile(shPath, []byte(shCommand), 0755) @@ -139,7 +139,7 @@ func Use(args []string) { // create bat script for php-cgi batCommandCGI := "@echo off \n" - batCommandCGI += "set " + envPHPRC + "\n" + batCommandCGI += "set " + envPHPFolder + "\n" batCommandCGI += "set filepath=\"" + versionPathCGI + "\"\n" batCommandCGI += "set arguments=%*\n" batCommandCGI += "%filepath% %arguments%\n" @@ -153,7 +153,7 @@ func Use(args []string) { // create sh script for php-cgi shCommandCGI := "#!/bin/bash\n" shCommandCGI += "filepath=\"" + versionPathCGI + "\"\n" - shCommandCGI += envPHPRC + " \"$filepath\" \"$@\"" + shCommandCGI += envPHPFolder + " \"$filepath\" \"$@\"" err = os.WriteFile(shPathCGI, []byte(shCommandCGI), 0755) From 10deed914d82d166cdab27b8365761b8caf2ddba Mon Sep 17 00:00:00 2001 From: Lotti Date: Thu, 2 Jan 2025 17:27:17 +0100 Subject: [PATCH 3/3] version bump --- commands/help.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commands/help.go b/commands/help.go index 8d4db06..c78074d 100644 --- a/commands/help.go +++ b/commands/help.go @@ -7,7 +7,7 @@ import ( func Help(notFoundError bool) { theme.Title("pvm: PHP Version Manager") - theme.Info("Version 1.1.1") + theme.Info("Version 1.1.2") if notFoundError { theme.Error("Command not found")