Skip to content

Commit

Permalink
More readable escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
jpm-canonical committed Aug 30, 2024
1 parent 94905af commit 255f62b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/thread_tests/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func remote_exec(t *testing.T, command string) string {
// Remote commands that require sudo might ask for the password. Always pass it in. See https://stackoverflow.com/a/11955358
if strings.HasPrefix(command, "sudo ") {
command = strings.TrimPrefix(command, "sudo ")
escapedPassword := strings.Replace(remotePassword, "\"", "\\\"", -1)
escapedPassword := strings.ReplaceAll(remotePassword, `"`, `\"`)
command = fmt.Sprintf(`echo "%s" | sudo -S %s`, escapedPassword, command)
}

Expand Down

0 comments on commit 255f62b

Please sign in to comment.