Skip to content

os/exec: BAT file under path including white-space cannot run specifying blank argument #9084

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

Closed
gopherbot opened this issue Nov 11, 2014 · 3 comments

Comments

@gopherbot
Copy link
Contributor

by nobeans:

What does 'go version' print?

go version go1.3.3 windows/386

What steps reproduce the problem?
If possible, include a link to a program on play.golang.org.

1. Copy https://gist.github.com/nobeans/1fcc22ea9268746455b0 to your local machine like
test-run-bat.go.
2. Create C:\\DIR WITH SPACES\\test.bat with a content like "echo Hello"
3. Run this script `go run test-run-bat.go`

What happened?

An unexpected error occurs to run a BAT file under a path having a white-space only when
specifying a blank argument.
The error message is like this:

'C:\DIR' is not recognized as an internal or external command,
operable program or batch file.

What should have happened instead?

It should be able to run successfully as running a exe file.

Please provide any additional information below.

It doesn't occur without a blank argument even for a BAT file in Windows.
It doesn't occur with/without a blank argument for a EXE file in Windows.
And it doesn't occur with any arguments in Mac and Linux.
@ianlancetaylor
Copy link
Member

Comment 1:

Labels changed: added repo-main, release-go1.5, os-windows.

@alexbrainman
Copy link
Member

Comment 2:

I think, that is how windows cmd.exe works. I did this:
C:\>cmd /c "C:\DIR WITH SPACES\test.bat"
C:\>echo Hello
Hello
C:\>cmd /c "C:\DIR WITH SPACES\test.bat" ""
'C:\DIR' is not recognized as an internal or external command,
operable program or batch file.
C:\>
which looks similar to what you see in your program.
I agree, it is inconsistent, but I think we should let Windows make rules here.
Alex

Status changed to Unfortunate.

@gesius
Copy link

gesius commented Jan 18, 2015

Problem exists also for the exec.go module for starting a process on windows. If you intend to support the windows plattform than this needs to be fixed.
And you are right: Windows make the rule as the Linux guys do and we try to follow...

@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants