Ondřej Vašík <[EMAIL PROTECTED]> wrote: > Hello, > I got recently got one complaint ( no rhbz number at the moment :( ) > about too verbose silent mode since using fts for directory traversal in > chmod/chown/chgrp. I guess those error messages should be suppressed in > silent mode. > Attached patch is doing that (making those error messages conditional). > > Greetings, > Ondřej Vašík
Thanks. I'm applying this. Will push in the next few days. However, I would have appreciated NEWS, a test, and consistent indentation. This first patch corrects the indentation. I'm folding it into your change. I've added a NEWS entry and wrote the test. They're below, along with the merged version of your patch: >From 98a9b61d5a4c2b113a4fefb61ea0c47bd3b1663a Mon Sep 17 00:00:00 2001 From: Jim Meyering <[EMAIL PROTECTED]> Date: Sat, 29 Nov 2008 11:07:18 +0100 Subject: [PATCH] indent consistently --- src/chmod.c | 6 +++--- src/chown-core.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/chmod.c b/src/chmod.c index 75a25a5..8c5cc3e 100644 --- a/src/chmod.c +++ b/src/chmod.c @@ -205,7 +205,7 @@ process_file (FTS *fts, FTSENT *ent) } if (! force_silent) error (0, ent->fts_errno, _("cannot access %s"), - quote (file_full_name)); + quote (file_full_name)); ok = false; break; @@ -218,14 +218,14 @@ process_file (FTS *fts, FTSENT *ent) case FTS_DNR: if (! force_silent) error (0, ent->fts_errno, _("cannot read directory %s"), - quote (file_full_name)); + quote (file_full_name)); ok = false; break; case FTS_SLNONE: if (! force_silent) error (0, 0, _("cannot operate on dangling symlink %s"), - quote (file_full_name)); + quote (file_full_name)); ok = false; default: diff --git a/src/chown-core.c b/src/chown-core.c index 9dbe374..cf0c941 100644 --- a/src/chown-core.c +++ b/src/chown-core.c @@ -298,7 +298,7 @@ change_file_owner (FTS *fts, FTSENT *ent, } if (! chopt->force_silent) error (0, ent->fts_errno, _("cannot access %s"), - quote (file_full_name)); + quote (file_full_name)); ok = false; break; @@ -311,7 +311,7 @@ change_file_owner (FTS *fts, FTSENT *ent, case FTS_DNR: if (! chopt->force_silent) error (0, ent->fts_errno, _("cannot read directory %s"), - quote (file_full_name)); + quote (file_full_name)); ok = false; break; @@ -344,7 +344,7 @@ change_file_owner (FTS *fts, FTSENT *ent, { if (! chopt->force_silent) error (0, errno, _("cannot dereference %s"), - quote (file_full_name)); + quote (file_full_name)); ok = false; } -- 1.6.0.4.1101.g642f8 >From 317ebb10c7856d74d7c10ad2afbc9cce7b9a4dd7 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= <[EMAIL PROTECTED]> Date: Thu, 27 Nov 2008 15:04:10 +0100 Subject: [PATCH 1/2] chmod, chown, chgrp: honor --silent (-f) once again * chmod.c (process_file): Make -f suppress fts-related diagnostics. * chown-core.c (change_file_owner): Likewise. --- src/chmod.c | 24 +++++++++++++++--------- src/chown-core.c | 20 +++++++++++++------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/chmod.c b/src/chmod.c index 80fc363..8c5cc3e 100644 --- a/src/chmod.c +++ b/src/chmod.c @@ -67,7 +67,7 @@ static mode_t umask_value; /* If true, change the modes of directories recursively. */ static bool recurse; -/* If true, force silence (no error messages). */ +/* If true, force silence (suppress most of error messages). */ static bool force_silent; /* If true, diagnose surprises from naive misuses like "chmod -r file". @@ -121,7 +121,7 @@ mode_changed (char const *file, mode_t old_mode, mode_t new_mode) if (stat (file, &new_stats) != 0) { - if (!force_silent) + if (! force_silent) error (0, errno, _("getting new attributes of %s"), quote (file)); return false; } @@ -203,24 +203,29 @@ process_file (FTS *fts, FTSENT *ent) fts_set (fts, ent, FTS_AGAIN); return true; } - error (0, ent->fts_errno, _("cannot access %s"), quote (file_full_name)); + if (! force_silent) + error (0, ent->fts_errno, _("cannot access %s"), + quote (file_full_name)); ok = false; break; case FTS_ERR: - error (0, ent->fts_errno, _("%s"), quote (file_full_name)); + if (! force_silent) + error (0, ent->fts_errno, _("%s"), quote (file_full_name)); ok = false; break; case FTS_DNR: - error (0, ent->fts_errno, _("cannot read directory %s"), - quote (file_full_name)); + if (! force_silent) + error (0, ent->fts_errno, _("cannot read directory %s"), + quote (file_full_name)); ok = false; break; case FTS_SLNONE: - error (0, 0, _("cannot operate on dangling symlink %s"), - quote (file_full_name)); + if (! force_silent) + error (0, 0, _("cannot operate on dangling symlink %s"), + quote (file_full_name)); ok = false; default: @@ -319,7 +324,8 @@ process_files (char **files, int bit_flags) if (errno != 0) { /* FIXME: try to give a better message */ - error (0, errno, _("fts_read failed")); + if (! force_silent) + error (0, errno, _("fts_read failed")); ok = false; } break; diff --git a/src/chown-core.c b/src/chown-core.c index 4ab52ac..cf0c941 100644 --- a/src/chown-core.c +++ b/src/chown-core.c @@ -296,18 +296,22 @@ change_file_owner (FTS *fts, FTSENT *ent, fts_set (fts, ent, FTS_AGAIN); return true; } - error (0, ent->fts_errno, _("cannot access %s"), quote (file_full_name)); + if (! chopt->force_silent) + error (0, ent->fts_errno, _("cannot access %s"), + quote (file_full_name)); ok = false; break; case FTS_ERR: - error (0, ent->fts_errno, _("%s"), quote (file_full_name)); + if (! chopt->force_silent) + error (0, ent->fts_errno, _("%s"), quote (file_full_name)); ok = false; break; case FTS_DNR: - error (0, ent->fts_errno, _("cannot read directory %s"), - quote (file_full_name)); + if (! chopt->force_silent) + error (0, ent->fts_errno, _("cannot read directory %s"), + quote (file_full_name)); ok = false; break; @@ -338,8 +342,9 @@ change_file_owner (FTS *fts, FTSENT *ent, { if (fstatat (fts->fts_cwd_fd, file, &stat_buf, 0) != 0) { - error (0, errno, _("cannot dereference %s"), - quote (file_full_name)); + if (! chopt->force_silent) + error (0, errno, _("cannot dereference %s"), + quote (file_full_name)); ok = false; } @@ -492,7 +497,8 @@ chown_files (char **files, int bit_flags, if (errno != 0) { /* FIXME: try to give a better message */ - error (0, errno, _("fts_read failed")); + if (! chopt->force_silent) + error (0, errno, _("fts_read failed")); ok = false; } break; -- 1.6.0.4.1101.g642f8 >From 0a4da8d4dfde1cea9b2fd0c3d84584fe05b2dad1 Mon Sep 17 00:00:00 2001 From: Jim Meyering <[EMAIL PROTECTED]> Date: Sat, 29 Nov 2008 10:47:12 +0100 Subject: [PATCH 2/2] tests: ensure that chmod, chgrp and chown honor --silent * tests/chmod/silent: New file, to test all three programs. * tests/Makefile.am (TESTS): Add chmod/silent. * NEWS (Bug fixes): Mention this. The bug was introduced in 96a5d2ce6a53d96cb667af78f13e56fadcdb91e6. --- NEWS | 3 +++ tests/Makefile.am | 1 + tests/chmod/silent | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 0 deletions(-) create mode 100755 tests/chmod/silent diff --git a/NEWS b/NEWS index 5bd9446..ae980b7 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,9 @@ GNU coreutils NEWS -*- outline -*- ** Bug fixes + chgrp, chmod, chown --silent (--quiet, -f) no longer print some diagnostics + [bug introduced in coreutils-5.1] + cp uses much less memory in some situations du --files0-from=FILE no longer reads all of FILE into RAM before diff --git a/tests/Makefile.am b/tests/Makefile.am index 307e5a8..8413fe9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -238,6 +238,7 @@ TESTS = \ chmod/inaccessible \ chmod/octal \ chmod/setgid \ + chmod/silent \ chmod/thru-dangling \ chmod/umask-x \ chmod/usage \ diff --git a/tests/chmod/silent b/tests/chmod/silent new file mode 100755 index 0000000..d61caf5 --- /dev/null +++ b/tests/chmod/silent @@ -0,0 +1,36 @@ +#!/bin/sh +# ensure that chgrp, chmod, chown -f don't print some diagnostics + +# 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/>. + +if test "$VERBOSE" = yes; then + set -x + chgrp --version + chmod --version + chown --version +fi + +. $srcdir/test-lib.sh + +fail=0 +chmod -f 0 no-such 2> out && fail=1 +chgrp -f 0 no-such 2>> out && fail=1 +chown -f 0:0 no-such 2>> out && fail=1 +touch exp || fail=1 + +compare out exp || fail=1 + +Exit $fail -- 1.6.0.4.1101.g642f8 _______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils