-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
os/exec: extraneous quote escaping in argument received by spawned program, on Windows #21739
Comments
@thanhps42 I've updated the issue title to the best that I could make out of the images that you posted. Is the issue that os/exec extraneously escapes quotes in arguments? If not, please help me update the title. I personally don't have access to a Windows computer but if anyone does, please feel free to reproduce and debug this bug. |
Please try
https://play.golang.org/p/Hju_Cl5m2Y
I suspect it will have the same result, but will be informative.
…On Sat, Sep 2, 2017 at 12:28 PM, thanhps42 ***@***.***> wrote:
I got wrong arg in exec.Command
What version of Go are you using (go version)?
go version go1.8.3 windows/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\Code\Go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
-fdebug-prefix-map=C:\Users\thanh\AppData\Local\Temp\go-build383552903=/tmp/go-build
-gno-record-gcc-switches
set CXX=g++
set CGO_ENABLED=1
set PKG_CONFIG=pkg-config
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
What did you do?
Call exec.Command.
Code: https://play.golang.org/p/rcCLuvKudm
What did you expect to see?
<https://camo.githubusercontent.com/335ba7d622c3d50560b914d9810c5f5e0384b625/68747470733a2f2f696d6167652e70726e747363722e636f6d2f696d6167652f383773546b4c696751336d42557439566263714435412e706e67>
What did you see instead?
<https://camo.githubusercontent.com/1da53b6dd6245acb9a386de142a14aae9b37b7b6/68747470733a2f2f696d6167652e70726e747363722e636f6d2f696d6167652f5a6733426e6979565255473652676a78335f48674b412e706e67>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#21739>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAcA2MNBFGTNfzuuXzRFj6T6b63rweNks5seL1AgaJpZM4PKxiA>
.
|
Yes, same result. |
That's what I thought, the escaping may be coming from something the windows version of the exec package is doing. Have you tried removing the quoting, it's probably not necessary
… On 2 Sep 2017, at 18:47, thanhps42 ***@***.***> wrote:
Yes, same result.
P/s: sorry for my bad English.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Yes, in my example, quoting is not necessary, but if argument is --profile-directory="Profile 1", i need quoting because i have spacing. |
As an experiment, try without the quotes, see what happens.
…On Sun, 3 Sep 2017, 10:31 thanhps42 ***@***.***> wrote:
Yes, in my example, quoting is not necessary, but if argument is *--profile-directory="Profile
1"*, i need quoting because i have spacing.
Thanks.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#21739 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAcA_FvtPBeWr6H99HTzIMH4lG8sm_jks5sefNfgaJpZM4PKxiA>
.
|
I have update my problem (please see picture again), can't work without quotes |
Thank you. I'm not a windows expert so I'll have to hand it off here
Perhaps this is not supported, or maybe you have to pass it through cmd.exe
to properly escape the arguments.
Perhaps you're supposed to escape spaces with backslash rather than quoting
them.
Paging @bketelsen @brainman.
…On Sun, 3 Sep 2017, 10:42 thanhps42 ***@***.***> wrote:
I have update my problem (please see picture again), can't work without
quotes
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#21739 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAAcAwovc24ZUl7bFGRtMgk0xLTYOkdXks5sefYIgaJpZM4PKxiA>
.
|
You do not need " to escape spaces inside the argument. When you use os/exec.Command to build Windows command, standard library should do all escaping you need. See makeCmdLine function in runtime package for details. So (I have not tested it)
should work. Please try it. Alex |
@alexbrainman Thanks for your help. It's work like a charm (y) |
I got wrong arg in exec.Command
What version of Go are you using (
go version
)?go version go1.8.3 windows/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\Code\Go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\thanh\AppData\Local\Temp\go-build383552903=/tmp/go-build -gno-record-gcc-switches
set CXX=g++
set CGO_ENABLED=1
set PKG_CONFIG=pkg-config
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
What did you do?
Call exec.Command.
Code: https://play.golang.org/p/NHfMcWdh45
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: