Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Quote in username errors dapr init #972 #1322

Merged
merged 9 commits into from
Jun 26, 2023
1 change: 1 addition & 0 deletions pkg/standalone/standalone.go
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ func moveFileToPath(filepath string, installLocation string) (string, error) {
p := os.Getenv("PATH")

if !strings.Contains(strings.ToLower(p), strings.ToLower(destDir)) {
utils.FixCommandWithApostrophe(&destDir)
pathCmd := "[System.Environment]::SetEnvironmentVariable('Path',[System.Environment]::GetEnvironmentVariable('Path','user') + '" + fmt.Sprintf(";%s", destDir) + "', 'user')"
_, err := utils.RunCmdAndWait("powershell", pathCmd)
if err != nil {
Expand Down
15 changes: 15 additions & 0 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,18 @@
}
return filePath, nil
}

// FixCommandWithApostrophe corrects the passed command which might have apostrophes in it

Check failure on line 407 in utils/utils.go

View workflow job for this annotation

GitHub Actions / Build linux_amd64 binaries

Comment should end in a period (godot)
func FixCommandWithApostrophe(destDir *string) {
mohitpalsingh marked this conversation as resolved.
Show resolved Hide resolved
bytes := []byte(*destDir)
var result []byte

for i := 0; i < len(bytes); i++ {
result = append(result, bytes[i])
if bytes[i] == '\'' {
result = append(result, '\'')
}
}

*destDir = string(result)
}
Loading