[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] split: --verbose output to stdout
From: |
Steven Schubiger |
Subject: |
Re: [PATCH] split: --verbose output to stdout |
Date: |
Wed, 23 Jan 2008 12:55:01 +0100 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
Jim Meyering <address@hidden> wrote:
> Steven Schubiger <address@hidden> wrote:
> > diff --git a/src/split.c b/src/split.c
> > index 5807a1c..2ad0baf 100644
> > --- a/src/split.c
> > +++ b/src/split.c
> > @@ -208,7 +208,7 @@ cwrite (bool new_file_flag, const char *bp, size_t
> > bytes)
> >
> > next_file_name ();
> > if (verbose)
> > - fprintf (stderr, _("creating file %s\n"), quote (outfile));
> > + fprintf (stdout, _("creating file %s\n"), quote (outfile));
> > output_desc = open (outfile,
> > O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
> > (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP
>
> That's probably ok. i.e., it's probably ok not to call fflush there.
>
> You'll want to adjust the help output, too:
>
> $ split --help|grep verb
> --verbose print a diagnostic to standard error just
>
> Please check the texinfo documentation, too.
> It'd be nice if you were to include a ChangeLog entry.
>
> No rush of course, since I won't apply such a change until
> after the upcoming stable release. In fact, why don't you
> do both split and mkdir at the same time, and then you can
> simply remove that item from TODO as part of the patch.
>
> Finally, please run "make check" or even "make distcheck"
> to make sure all tests pass with your changes.
Patch attached (mkdir & split).
FYI, make check passes, whereas make distcheck bails out with:
./gnulib/ChangeLog:105: Bruno Haible <address@hidden>
./gnulib/ChangeLog:37711:Copyright (C) 1997-2008 Free Software Foundation, Inc.
./gnulib/ChangeLog:37712:Copying and distribution of this file, with or without
modification,
./gnulib/ChangeLog:37713:are permitted provided the copyright notice and this
notice are preserved.
Makefile.maint: found unexpected prefix in a ChangeLog
make[2]: *** [sc_changelog] Error 1
make[2]: Leaving directory `/home/sts/code/foreign/coreutils'
make[1]: *** [distcheck-hook] Error 2
make[1]: Leaving directory `/home/sts/code/foreign/coreutils'
make: *** [distcheck] Error 2
Steven Schubiger
diff --git a/ChangeLog b/ChangeLog
index 7643c87..6a892c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2008-01-23 Steven Schubiger <address@hidden>
+
+ * src/mkdir.c: Send --verbose output to stdout.
+ * src/split.c: Likewise.
+ Update texinfo documentation for split.
+ Adjust tests for mkdir/split.
+ * tests/mkdir/p-v: Capture verbose output which previously was
+ being emitted to stderr from stdout.
+ * tests/misc/split-a: Likewise.
+
2008-01-18 Jim Meyering <address@hidden>
Update README.
diff --git a/TODO b/TODO
index df07d4b..30b14be 100644
--- a/TODO
+++ b/TODO
@@ -46,14 +46,6 @@ And once that's done, add an exclusion so that `cp --link'
no longer incurs the overhead of saving src. dev/ino and dest. filename
in the hash table.
-See if we can be consistent about where --verbose sends its output:
- These all send --verbose output to stdout:
- head, tail, rm, cp, mv, ln, chmod, chown, chgrp, install, ln
- These send it to stderr:
- shred mkdir split
- shred must write --verbose output to stderr
- readlink is different
-
Write an autoconf test to work around build failure in HPUX's 64-bit mode.
See notes in README -- and remove them once there's a work-around.
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 5043a8f..9061479 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2008-01-23 Steven Schubiger <address@hidden>
+
+ * coreutils.texi (split invocation): Removed the mention
+ of --verbose output being printed to stderr.
+
2007-10-05 Jim Meyering <address@hidden>
* coreutils.texi (chroot invocation): List two systems on which
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 3785eae..cf8a730 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -2838,7 +2838,7 @@ Use digits in suffixes rather than lower-case letters.
@itemx --verbose
@opindex --verbose
-Write a diagnostic to standard error just before each output file is opened.
+Write a diagnostic just before each output file is opened.
@end table
diff --git a/src/mkdir.c b/src/mkdir.c
index 0704077..39ae97a 100644
--- a/src/mkdir.c
+++ b/src/mkdir.c
@@ -1,5 +1,5 @@
/* mkdir -- make directories
- Copyright (C) 90, 1995-2002, 2004-2007 Free Software Foundation, Inc.
+ Copyright (C) 90, 1995-2002, 2004-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
@@ -99,13 +99,26 @@ struct mkdir_options
char const *created_directory_format;
};
+/* Verbose formatted output of variable count of arguments. */
+static void
+verbose_output (const char const *fmt, ...)
+{
+ va_list ap;
+ va_start (ap, fmt);
+ fprintf (stdout, "%s: ", program_name);
+ vfprintf (stdout, fmt, ap);
+ fprintf (stdout, "\n");
+ fflush (stdout);
+ va_end (ap);
+}
+
/* Report that directory DIR was made, if OPTIONS requests this. */
static void
announce_mkdir (char const *dir, void *options)
{
struct mkdir_options const *o = options;
if (o->created_directory_format)
- error (0, 0, o->created_directory_format, quote (dir));
+ verbose_output (o->created_directory_format, quote (dir));
}
/* Make ancestor directory DIR, whose last component is COMPONENT,
diff --git a/src/split.c b/src/split.c
index 5807a1c..f84d40e 100644
--- a/src/split.c
+++ b/src/split.c
@@ -1,5 +1,5 @@
/* split.c -- split a file into pieces.
- Copyright (C) 1988, 1991, 1995-2007 Free Software Foundation, Inc.
+ Copyright (C) 1988, 1991, 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
@@ -122,8 +122,8 @@ Mandatory arguments to long options are mandatory for short
options too.\n\
-l, --lines=NUMBER put NUMBER lines per output file\n\
"), DEFAULT_SUFFIX_LENGTH);
fputs (_("\
- --verbose print a diagnostic to standard error just\n\
- before each output file is opened\n\
+ --verbose print a diagnostic just before each\n\
+ output file is opened\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
@@ -208,7 +208,7 @@ cwrite (bool new_file_flag, const char *bp, size_t bytes)
next_file_name ();
if (verbose)
- fprintf (stderr, _("creating file %s\n"), quote (outfile));
+ fprintf (stdout, _("creating file %s\n"), quote (outfile));
output_desc = open (outfile,
O_WRONLY | O_CREAT | O_TRUNC | O_BINARY,
(S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP
diff --git a/tests/misc/split-a b/tests/misc/split-a
index 794115f..a8eed38 100755
--- a/tests/misc/split-a
+++ b/tests/misc/split-a
@@ -1,7 +1,7 @@
#!/bin/sh
# Show that split -a works.
-# Copyright (C) 2002-2007 Free Software Foundation, Inc.
+# Copyright (C) 2002-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
@@ -39,7 +39,7 @@ test -f xaz && fail=1
rm -f x*
# With a longer suffix, it must succeed.
-split --verbose -b 1 -a 2 in 2> err || fail=1
+split --verbose -b 1 -a 2 in > err || fail=1
test -f xaa || fail=1
test -f xaz || fail=1
test -f xba || fail=1
diff --git a/tests/mkdir/p-v b/tests/mkdir/p-v
index 2c84b41..569e9b0 100755
--- a/tests/mkdir/p-v
+++ b/tests/mkdir/p-v
@@ -1,7 +1,7 @@
#!/bin/sh
# Test mkdir -pv.
-# Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2006-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
@@ -24,7 +24,7 @@ fi
. $srcdir/../lang-default
. $srcdir/../test-lib.sh
-mkdir -pv foo/a/b/c/d 2>out || exit
+mkdir -pv foo/a/b/c/d >out || exit
diff - out <<\EOF
mkdir: created directory `foo'