summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndřej Vašík <ovasik@redhat.com>2008-03-10 17:03:41 +0100
committerJim Meyering <meyering@redhat.com>2008-03-10 19:47:15 +0100
commit9c393fa1944e5decb2838de7cbcf6b371717fd77 (patch)
tree2231be9b72506005a058543193e659120bb121c6
parent3c7a6ae340feee50ed6368ff9224aa3a29fff97e (diff)
downloadcoreutils-9c393fa1944e5decb2838de7cbcf6b371717fd77.tar.xz
install, rmdir: write --verbose output to stdout, not to stderr.
* src/install.c (announce_mkdir): Write verbose output to stdout, not to stderr. * src/mkdir.c (announce mkdir): Use prog_fprintf for verbose output. * src/prog-fprintf.c (prog_fprintf): New function and file. * src/prog-fprintf.h: New file. * src/rmdir.c (main): Write verbose output to stdout, not to stderr. Quote directory name in a diagnostic. * src/rmdir.c (remove_parents): Write verbose output to stdout, not to stderr. * doc/coreutils.texi: Mention that shred verbose output is to stderr. * NEWS: Mention the changes. Signed-off-by: Ondřej Vašík <ovasik@redhat.com>
-rw-r--r--NEWS3
-rw-r--r--doc/coreutils.texi2
-rw-r--r--src/Makefile.am6
-rw-r--r--src/install.c5
-rw-r--r--src/mkdir.c16
-rw-r--r--src/prog-fprintf.c37
-rw-r--r--src/prog-fprintf.h24
-rw-r--r--src/rmdir.c7
8 files changed, 78 insertions, 22 deletions
diff --git a/NEWS b/NEWS
index a738dab1b..948bcede7 100644
--- a/NEWS
+++ b/NEWS
@@ -40,7 +40,8 @@ GNU coreutils NEWS -*- outline -*-
** Consistency
- mkdir and split now write --verbose output to stdout, not stderr.
+ install, mkdir, rmdir and split now write --verbose output to stdout,
+ not to stderr.
* Noteworthy changes in release 6.10 (2008-01-22) [stable]
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index df6792d7e..f161c4d65 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -8190,7 +8190,7 @@ If a file has multiple links, only the named links will be removed.
@itemx --verbose
@opindex -v
@opindex --verbose
-Display status updates as sterilization proceeds.
+Display to standard error all status updates as sterilization proceeds.
@item -x
@itemx --exact
diff --git a/src/Makefile.am b/src/Makefile.am
index c85f85365..44d802e15 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -54,6 +54,7 @@ noinst_HEADERS = \
fs.h \
group-list.h \
ls.h \
+ prog-fprintf.h \
remove.h \
system.h \
wheel-size.h \
@@ -203,7 +204,7 @@ copy_sources = copy.c cp-hash.c
# to install before applying any user-specified name transformations.
transform = s/ginstall/install/; @program_transform_name@
-ginstall_SOURCES = install.c $(copy_sources)
+ginstall_SOURCES = install.c prog-fprintf.c $(copy_sources)
# This is for the '[' program. Automake transliterates '[' to '_'.
__SOURCES = lbracket.c
@@ -221,6 +222,9 @@ chgrp_SOURCES = chgrp.c chown-core.c
mv_SOURCES = mv.c remove.c $(copy_sources)
rm_SOURCES = rm.c remove.c
+mkdir_SOURCES = mkdir.c prog-fprintf.c
+rmdir_SOURCES = rmdir.c prog-fprintf.c
+
uname_SOURCES = uname.c uname-uname.c
arch_SOURCES = uname.c uname-arch.c
diff --git a/src/install.c b/src/install.c
index db08751e4..1d04373b1 100644
--- a/src/install.c
+++ b/src/install.c
@@ -1,5 +1,5 @@
/* install - copy files and set attributes
- Copyright (C) 89, 90, 91, 1995-2007 Free Software Foundation, Inc.
+ Copyright (C) 89, 90, 91, 1995-2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -34,6 +34,7 @@
#include "mkancesdirs.h"
#include "mkdir-p.h"
#include "modechange.h"
+#include "prog-fprintf.h"
#include "quote.h"
#include "quotearg.h"
#include "savewd.h"
@@ -762,7 +763,7 @@ announce_mkdir (char const *dir, void *options)
{
struct cp_options const *x = options;
if (x->verbose)
- error (0, 0, _("creating directory %s"), quote (dir));
+ prog_fprintf (stdout, _("creating directory %s"), quote (dir));
}
/* Make ancestor directory DIR, whose last file name component is
diff --git a/src/mkdir.c b/src/mkdir.c
index 378106501..395259413 100644
--- a/src/mkdir.c
+++ b/src/mkdir.c
@@ -27,6 +27,7 @@
#include "lchmod.h"
#include "mkdir-p.h"
#include "modechange.h"
+#include "prog-fprintf.h"
#include "quote.h"
#include "savewd.h"
@@ -79,19 +80,6 @@ Mandatory arguments to long options are mandatory for short options too.\n\
exit (status);
}
-/* Verbose formatted output of variable count of arguments. */
-static void
-verbose_output (FILE *fp, char const *fmt, ...)
-{
- va_list ap;
- fputs (program_name, fp);
- fputs (": ", fp);
- va_start (ap, fmt);
- vfprintf (fp, fmt, ap);
- va_end (ap);
- fputc ('\n', fp);
-}
-
/* Options passed to subsidiary functions. */
struct mkdir_options
{
@@ -118,7 +106,7 @@ announce_mkdir (char const *dir, void *options)
{
struct mkdir_options const *o = options;
if (o->created_directory_format)
- verbose_output (stdout, o->created_directory_format, quote (dir));
+ prog_fprintf (stdout, o->created_directory_format, quote (dir));
}
/* Make ancestor directory DIR, whose last component is COMPONENT,
diff --git a/src/prog-fprintf.c b/src/prog-fprintf.c
new file mode 100644
index 000000000..85aceb61f
--- /dev/null
+++ b/src/prog-fprintf.c
@@ -0,0 +1,37 @@
+/* prog-fprintf.c - common formating output functions and definitions
+ Copyright (C) 2008 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+#include <stdarg.h>
+#include <sys/types.h>
+
+#include "prog-fprintf.h"
+
+extern char *program_name;
+
+/* Display program name followed by variable list.
+ Used for e.g. verbose output */
+void
+prog_fprintf (FILE *fp, char const *fmt, ...)
+{
+ va_list ap;
+ fputs (program_name, fp);
+ fputs (": ", fp);
+ va_start (ap, fmt);
+ vfprintf (fp, fmt, ap);
+ va_end (ap);
+ fputc ('\n', fp);
+}
diff --git a/src/prog-fprintf.h b/src/prog-fprintf.h
new file mode 100644
index 000000000..d5c3d425a
--- /dev/null
+++ b/src/prog-fprintf.h
@@ -0,0 +1,24 @@
+/* prog-fprintf.h - common formating output functions and definitions
+ Copyright (C) 2008 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef PROG_FPRINTF_H
+# define PROG_FPRINTF_H
+
+# include <stdio.h>
+
+extern void prog_fprintf (FILE *fp, char const *fmt, ...);
+
+#endif
diff --git a/src/rmdir.c b/src/rmdir.c
index bb1a0c8b3..5f7f54116 100644
--- a/src/rmdir.c
+++ b/src/rmdir.c
@@ -1,6 +1,6 @@
/* rmdir -- remove directories
- Copyright (C) 90, 91, 1995-2002, 2004, 2005, 2006, 2007 Free Software
+ Copyright (C) 90, 91, 1995-2002, 2004-2008 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -30,6 +30,7 @@
#include "system.h"
#include "error.h"
+#include "prog-fprintf.h"
#include "quote.h"
/* The official name of this program (e.g., no `g' prefix). */
@@ -134,7 +135,7 @@ remove_parents (char *dir)
/* Give a diagnostic for each attempted removal if --verbose. */
if (verbose)
- error (0, 0, _("removing directory, %s"), quote (dir));
+ prog_fprintf (stdout, _("removing directory, %s"), quote (dir));
ok = (rmdir (dir) == 0);
@@ -233,7 +234,7 @@ main (int argc, char **argv)
/* Give a diagnostic for each attempted removal if --verbose. */
if (verbose)
- error (0, 0, _("removing directory, %s"), dir);
+ prog_fprintf (stdout, _("removing directory, %s"), quote (dir));
if (rmdir (dir) != 0)
{