Skip to content
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

cmd/go: -n flag shows Bash commands on all platforms. #5274

Closed
gopherbot opened this issue Apr 12, 2013 · 8 comments
Closed

cmd/go: -n flag shows Bash commands on all platforms. #5274

gopherbot opened this issue Apr 12, 2013 · 8 comments

Comments

@gopherbot
Copy link

by toqueteos:

Before filing a bug, please check whether it has been fixed since the
latest release. Search the issue tracker and check that you're running the
latest version of Go:

Run "go version" and compare against
http://golang.org/doc/devel/release.html  If a newer version of Go exists,
install it and retry what you did to reproduce the problem.

Thanks.

What steps will reproduce the problem?
go clean/build/get -n package

What is the expected output?
"del /F" instead of "rm -f"
"mkdir" instead of "mkdir -p" (if extensions allowed, if not mkdir +
cd madness)
"copy" instead of "cp"

What do you see instead?
D:\>go clean -n github.com/toqueteos/webbrowser
cd ...\go\src\github.com\toqueteos\webbrowser
rm -f webbrowser webbrowser.exe webbrowser.test webbrowser.test.exe

D:\>go get -n github.com/toqueteos/webbrowser

#
# os/exec
#

mkdir -p $WORK\os\exec\_obj\
cd C:\go\src\pkg\os\exec
C:\go\pkg\tool\windows_amd64\6g.exe -o $WORK\os\exec\_obj\_go_.6 -p os/exec -D
_/C_/go/src/pkg/os/exec -I $WORK .\exec.go .\lp_windows.go
C:\go\pkg\tool\windows_amd64\pack.exe grcP $WORK $WORK\os\exec.a
$WORK\os\exec\_obj\_go_.6
mkdir -p C:\go\pkg\windows_amd64\os\
cp $WORK\os\exec.a C:\go\pkg\windows_amd64\os\exec.a

#
# github.com/toqueteos/webbrowser
#

mkdir -p $WORK\github.com\toqueteos\webbrowser\_obj\
cd ...\go\src\github.com\toqueteos\webbrowser
C:\go\pkg\tool\windows_amd64\6g.exe -o $WORK\github.com\toqueteos\webbrowser\_obj\_go_.6
-p github.com/toqueteos/webbrowser -D
_/D_/Carlos/Dropbox/code/go/src/github.com/toqueteos/webbrowser -I $WORK .\doc.go
.\webbrowser.go
C:\go\pkg\tool\windows_amd64\pack.exe grcP $WORK $WORK\github.com\toqueteos\webbrowser.a
$WORK\github.com\toqueteos\webbrowser\_obj\_go_.6
mkdir -p ...\go\pkg\windows_amd64\github.com\toqueteos\
cp $WORK\github.com\toqueteos\webbrowser.a
...\go\pkg\windows_amd64\github.com\toqueteos\webbrowser.a


Which compiler are you using (5g, 6g, 8g, gccgo)?
6g

Which operating system are you using?
Windows 7 Enterprise x64

Which version are you using?  (run 'go version')
go version go1.0.3

---

Elided user related paths with "...".

Quick fixes possible:
- String replace operation.
- A note on top of output for Windows users.
@alexbrainman
Copy link
Member

Comment 1:

Checking the source:
# pwd
/root/go/root/src/cmd/go
sob go # grep showcmd *
build.go:               b.showcmd("", "cp %s %s", src, dst)
build.go:// showcmd prints the given command to standard output
build.go:func (b *builder) showcmd(dir string, format string, args ...interface{}) {
build.go:               b.showcmd(dir, "%s", strings.Join(cmdline, " "))
build.go:               b.showcmd("", "mkdir -p %s", dir)
clean.go:               b.showcmd(p.Dir, "rm -f %s", strings.Join(allRemove, " "))
clean.go:                                       b.showcmd(p.Dir, "rm -r %s", name)
clean.go:                       b.showcmd("", "rm -f %s", p.target)
clean.go:                               b.showcmd("", "rm -f %s", target)
run.go:         b.showcmd("", "%s %s", a.deps[0].target, strings.Join(a.args, " "))
test.go:                b.showcmd("", "%s", strings.Join(args, " "))
#
I can see possible candidates:
cp
mkdir -p
rm -f
rm -r
Assuming Go Authors would agree to change it, what would your replacements be? Your
proposed alternatives aren't quite the same: "copy" and "del /f", unlike "cp" and "rm
-f", will sometimes ask user questions.
As to paths with "...", I don't have those. Perhaps, because I use tip. Can you, please,
try tip or latest go1.1beta.
Thank you.
Alex

Status changed to WaitingForReply.

@gopherbot
Copy link
Author

Comment 2 by toqueteos:

Sorry Alex.
My suggestions may be incomplete becausd I reported this in a hurry.ñ,
sorry about that, there are flags to avoid asking the user.
I replaced those "..." by hand to make paths shorter they just pointed to
my GOPATH I can add the original result later (it's 4:51 AM here, I need
some sleep :/) if you want, it's something like "D:\Carlos\Dropbox\code\go"
El 12/04/2013 04:44, <go@googlecode.com> escribió:

@alexbrainman
Copy link
Member

Comment 3:

But "del /f" does not delete directories ("rm -f" does). How are you going to handle
these?
Alex

@gopherbot
Copy link
Author

Comment 4 by toqueteos:

Here is the full input of the commands:
-----------------------------------------------------------------------------------------
D:\>go clean -n github.com/toqueteos/webbrowser
cd D:\Carlos\Dropbox\code\go\src\github.com\toqueteos\webbrowser
rm -f webbrowser webbrowser.exe webbrowser.test webbrowser.test.exe
-----------------------------------------------------------------------------------------
D:\>go build -n github.com/toqueteos/webbrowser
#
# os/exec
#
mkdir -p $WORK\os\exec\_obj\
cd C:\go\src\pkg\os\exec
C:\go\pkg\tool\windows_amd64\6g.exe -o $WORK\os\exec\_obj\_go_.6 -p os/exec -D
_/C_/go/src/pkg/os/exec -I $WORK .\exec.go .\lp_windows.go
C:\go\pkg\tool\windows_amd64\pack.exe grcP $WORK $WORK\os\exec.a
$WORK\os\exec\_obj\_go_.6
#
# github.com/toqueteos/webbrowser
#
mkdir -p $WORK\github.com\toqueteos\webbrowser\_obj\
cd D:\Carlos\Dropbox\code\go\src\github.com\toqueteos\webbrowser
C:\go\pkg\tool\windows_amd64\6g.exe -o $WORK\github.com\toqueteos\webbrowser\_obj\_go_.6
-p github.com/toqueteos/webbrowser -D
_/D_/Carlos/Dropbox/code/go/src/github.com/toqueteos/webbrowser -I $WORK .\doc.go
.\webbrowser.go
C:\go\pkg\tool\windows_amd64\pack.exe grcP $WORK $WORK\github.com\toqueteos\webbrowser.a
$WORK\github.com\toqueteos\webbrowser\_obj\_go_.6
-----------------------------------------------------------------------------------------
D:\>go get -n github.com/toqueteos/webbrowser
#
# os/exec
#
mkdir -p $WORK\os\exec\_obj\
cd C:\go\src\pkg\os\exec
C:\go\pkg\tool\windows_amd64\6g.exe -o $WORK\os\exec\_obj\_go_.6 -p os/exec -D
_/C_/go/src/pkg/os/exec -I $WORK .\exec.go .\lp_windows.go
C:\go\pkg\tool\windows_amd64\pack.exe grcP $WORK $WORK\os\exec.a
$WORK\os\exec\_obj\_go_.6
mkdir -p C:\go\pkg\windows_amd64\os\
cp $WORK\os\exec.a C:\go\pkg\windows_amd64\os\exec.a
#
# github.com/toqueteos/webbrowser
#
mkdir -p $WORK\github.com\toqueteos\webbrowser\_obj\
cd D:\Carlos\Dropbox\code\go\src\github.com\toqueteos\webbrowser
C:\go\pkg\tool\windows_amd64\6g.exe -o $WORK\github.com\toqueteos\webbrowser\_obj\_go_.6
-p github.com/toqueteos/webbrowser -D
_/D_/Carlos/Dropbox/code/go/src/github.com/toqueteos/webbrowser -I $WORK .\doc.go
.\webbrowser.go
C:\go\pkg\tool\windows_amd64\pack.exe grcP $WORK $WORK\github.com\toqueteos\webbrowser.a
$WORK\github.com\toqueteos\webbrowser\_obj\_go_.6
mkdir -p D:\Carlos\Dropbox\code\go\pkg\windows_amd64\github.com\toqueteos\
cp $WORK\github.com\toqueteos\webbrowser.a
D:\Carlos\Dropbox\code\go\pkg\windows_amd64\github.com\toqueteos\webbrowser.a
-----------------------------------------------------------------------------------------
It's not as trivial as I thought yesterday.
Most of the time use an Ubuntu VM or MinGW so I can't help that much on this issue.
- "del /F /Q" may behave the same as "rm -f".
- "rmdir" (win) needs extensions to behave the same as "mkdir -p" (bash).
There's also a third option which requires a bit more time, making a new go subcmd, such
as replay:
"go replay build github.com/toqueteos/webbrowser"
And it does take the input and uses "os" and "os/exec" libraries to replay all the steps.

@bjkail
Copy link

bjkail commented Apr 12, 2013

Comment 5:

I use 'rmdir /s/q dir' as 'rm -r'.
'mkdir a\b\c' behaves like 'mkdir -p' if 'setlocal enableextensions', which seems to be
the default on my Windows XP / 7 pro machines.

@gopherbot
Copy link
Author

Comment 6 by toqueteos:

There's a typo on #4: it's "mkdir" not "rmdir".
I'm sorry.

@robpike
Copy link
Contributor

robpike commented Apr 12, 2013

Comment 7:

Status changed to Duplicate.

Merged into issue #5279.

@alexbrainman
Copy link
Member

Comment 8:

Moving conversation here https://golang.org/issue/5279?c=3.
Alex

@golang golang locked and limited conversation to collaborators Jun 24, 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

4 participants