-
Notifications
You must be signed in to change notification settings - Fork 29
Make argument quotation compatible with cygwin/msys2/gitbash on Windows #97
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
@AkihiroSuda could you take a look? |
@@ -252,6 +252,16 @@ func (rsf *ReverseSSHFS) Start() error { | |||
return nil | |||
} | |||
|
|||
func addQuotes(input string) string { | |||
input = strconv.Quote(input) | |||
if runtime.GOOS == "windows" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment to explain the reason?
Also, can we have a unit test and/or an integration test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will try to sketch the unit test. It will take some time, I will ping you, when it is done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I managed to get a reproducer with a command line example. The command is extracted using recording processes started on the host.
"C:\Program Files\Git\usr\bin\ssh.exe" -i /c/Users/User/.local/share/containers/podman/machine/machine -p 60251 core@localhost -- mkdir -p \"/c/Users/runneradmin\"
bash: -c: line 1: unexpected EOF while looking for matching `"'
I don't think this can be reasonably covered by integration test - this would recover spinning VM just for that test.
And the method in question is not unit testable as it actually executes the resulting external commands within itself.
It would be only possible to cover private addQuotes with a unit test, which is actually a single standard library call on all platforms other than Windows, but I will add it and add the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added basic unit test and also extended test matrix to include Windows.
d6572fa
to
6c1fa18
Compare
Signed-off-by: Arthur Sengileyev <arthur.sengileyev@gmail.com>
6c1fa18
to
f469c85
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
It is the same situation like in https://github.com/lima-vm/lima/blob/786c1f5f3c6e8ff276c0c5d6789cdd9243d70f49/pkg/sshutil/sshutil.go#L271
Windows based tooling can't correctly escape
"
.The implemented workaround probably will not work for some extreme cases, but at least it is not failing outright from the start.
It has been tested to work on Windows with Git Bash and WSL2 based tooling.