golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.28k stars 17.47k forks source link

cmd/go: print shell commands safely #5279

Open robpike opened 11 years ago

robpike commented 11 years ago
The printing of commands by the go tool is simple-minded, can be incorrect in the face
of empty strings and other issues, ignores system-dependent issues ($foo vs %foo;
quoting, etc.) and should be improved. The current setup just calls Printf or special
formatting routines that sometimes (not always) expand variables, and ignore local
quoting and other conventions (rm vs. del for example). It's not important but it is
worth doing right.

It's a big job.
robpike commented 11 years ago

Comment 1:

Issue #5274 has been merged into this issue.

gopherbot commented 11 years ago

Comment 2 by toqueteos:

I'm sorry Rob I forgot to search for "shell".
Is the idea of a replay command suitable or it's better to ouput native shell commands?
alexbrainman commented 11 years ago

Comment 3:

To sumup from https://golang.org/issue/5274. Possible unix to
windows command translation candidates:
"cp" -> "copy /y" 
"mkdir -p" -> "mkdir"
"rm -f" -> "del /f /q" for files and "rmdir /s /q" for directories
"rm -r" -> same as before
Alex
alexbrainman commented 11 years ago

Comment 4:

Issue #5274 has been merged into this issue.

rsc commented 11 years ago

Comment 5:

I am not sure it is worth doing right.
The printing of commands by the go tool is meant to be informational, not a working
shell script.
alexbrainman commented 11 years ago

Comment 6:

I am with rsc on this. I suspect correct windows translation could be complicated (too
many unusual parameters options) or impossible to do correctly. I think clarity is most
important here.
Alex
rsc commented 10 years ago

Comment 7:

Labels changed: added go1.3maybe.

rsc commented 10 years ago

Comment 8:

Labels changed: added release-none, removed go1.3maybe.

rsc commented 10 years ago

Comment 9:

Labels changed: added repo-main.

bcmills commented 4 years ago

The printing of commands by the go tool is meant to be informational, not a working shell script.

As of CL 55350 (for #21427), we do have a test that the output of at least a very basic go build -x is a working shell script.