cmd/dist: Make verbose messages print to stderr

Made the following changes:
 - Export errprintf() from all three OS-specific modules
 - Added errprintf() to a.h
 - Moved errprintf() in windows.c under xprintf(), since they are so similar
 - Replaced all instances of xprintf() with errprintf() where a vflag check is done
Fixes #3788.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/6346056
This commit is contained in:
Pieter Droogendijk 2012-07-06 15:00:18 +10:00 committed by Alex Brainman
parent b213891c06
commit 34b10d7482
5 changed files with 56 additions and 33 deletions

19
src/cmd/dist/unix.c vendored
View file

@ -177,7 +177,7 @@ genrun(Buf *b, char *dir, int mode, Vec *argv, int wait)
bwritestr(&cmd, q);
}
if(vflag > 1)
xprintf("%s\n", bstr(&cmd));
errprintf("%s\n", bstr(&cmd));
if(b != nil) {
breset(b);
@ -398,7 +398,7 @@ void
xremove(char *p)
{
if(vflag > 2)
xprintf("rm %s\n", p);
errprintf("rm %s\n", p);
unlink(p);
}
@ -420,11 +420,11 @@ xremoveall(char *p)
xremoveall(bstr(&b));
}
if(vflag > 2)
xprintf("rm %s\n", p);
errprintf("rm %s\n", p);
rmdir(p);
} else {
if(vflag > 2)
xprintf("rm %s\n", p);
errprintf("rm %s\n", p);
unlink(p);
}
@ -627,6 +627,17 @@ xprintf(char *fmt, ...)
va_end(arg);
}
// errprintf prints a message to standard output.
void
errprintf(char *fmt, ...)
{
va_list arg;
va_start(arg, fmt);
vfprintf(stderr, fmt, arg);
va_end(arg);
}
// xsetenv sets the environment variable $name to the given value.
void
xsetenv(char *name, char *value)