Hello *,
this is not (really) a bug report but a RFC for a new feature/option
which I'm already using for years (based on request of some colleagues).
this quiet-option might be usefull for other tar users too, so here is my patch
(attached).
rationale for the patch: using "tar --compare" gives very verbose output
if owner/group/permissions have changed (e.g. when extracting a source tar file
from the net and later I'd like to check which source files I have
modified/patched).
this makes it somewhat hard not to miss the "important" output lines (e.g.
size/md5 changed).
the patch adds a new option "-Q" or "--quiet" which gives adds two "quiet
levels"
(giving 3 verbosity level alltogether: "normal default", "reasonable quiet"
and "completely quiet" (more or less a > /dev/null) when specified twice).
over the time, I only use the first quiet level, the additional "-QQ" feature
seems to be more or less academic to me today;-)
my typical usage is
tar zdQf tool-sources.tar.gz
which shows "exactly" the relevant changes/filenames to me...
any comments or takers?
thanks,
Harald Koenig
--
"I hope to die ___ _____
before I *have* to use Microsoft Word.", 0--,| /OOOOOOO\
Donald E. Knuth, 02-Oct-2001 in Tuebingen. <_/ / /OOOOOOOOOOO\
\ \/OOOOOOOOOOOOOOO\
\ OOOOOOOOOOOOOOOOO|//
Harald Koenig \/\/\/\/\/\/\/\/\/
science+computing ag // / \\ \
[EMAIL PROTECTED] ^^^^^ ^^^^^
--
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Florian Geyer,
Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Prof. Dr. Hanns Ruder
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196
diff -ur orig.003098/tar-1.19/lib/paxlib.h tar-1.19/lib/paxlib.h
--- orig.003098/tar-1.19/lib/paxlib.h 2007-06-27 15:49:45.000000000 +0200
+++ tar-1.19/lib/paxlib.h 2008-01-08 14:18:36.000000000 +0100
@@ -23,6 +23,7 @@
#include <hash.h>
#include <inttostr.h>
+extern int quiet_option;
/* Error reporting functions and definitions */
@@ -42,7 +43,9 @@
is zero when the error is not being detected by the system. */
#define WARN(Args) \
- error Args
+ do { if (quiet_option<2) error Args ; } while (0)
+#define WARN1(Args) \
+ do { if (quiet_option<1) error Args ; } while (0)
#define ERROR(Args) \
(error Args, exit_status = PAXEXIT_FAILURE)
#define FATAL_ERROR(Args) \
diff -ur orig.003098/tar-1.19/src/common.h tar-1.19/src/common.h
--- orig.003098/tar-1.19/src/common.h 2007-09-26 23:42:25.000000000 +0200
+++ tar-1.19/src/common.h 2008-01-08 14:18:36.000000000 +0100
@@ -235,6 +235,9 @@
just -1 if such an override should not take place. */
GLOBAL uid_t owner_option;
+/* Boolean value. */
+GLOBAL int quiet_option;
+
GLOBAL bool recursive_unlink_option;
GLOBAL bool read_full_records_option;
diff -ur orig.003098/tar-1.19/src/compare.c tar-1.19/src/compare.c
--- orig.003098/tar-1.19/src/compare.c 2007-08-26 10:56:55.000000000 +0200
+++ tar-1.19/src/compare.c 2008-01-08 14:18:36.000000000 +0100
@@ -200,16 +200,16 @@
{
if ((current_stat_info.stat.st_mode & MODE_ALL) !=
(stat_data.st_mode & MODE_ALL))
- report_difference (¤t_stat_info, _("Mode differs"));
+ report_difference (¤t_stat_info, (quiet_option) ? NULL : _("Mode
differs"));
if (!sys_compare_uid (&stat_data, ¤t_stat_info.stat))
- report_difference (¤t_stat_info, _("Uid differs"));
+ report_difference (¤t_stat_info, (quiet_option) ? NULL : _("Uid
differs"));
if (!sys_compare_gid (&stat_data, ¤t_stat_info.stat))
- report_difference (¤t_stat_info, _("Gid differs"));
+ report_difference (¤t_stat_info, (quiet_option) ? NULL : _("Gid
differs"));
if (tar_timespec_cmp (get_stat_mtime (&stat_data),
current_stat_info.mtime))
- report_difference (¤t_stat_info, _("Mod time differs"));
+ report_difference (¤t_stat_info, (quiet_option) ? NULL : _("Mod
time differs"));
if (current_header->header.typeflag != GNUTYPE_SPARSE
&& stat_data.st_size != current_stat_info.stat.st_size)
{
@@ -325,7 +325,7 @@
if ((current_stat_info.stat.st_mode & MODE_ALL) !=
(stat_data.st_mode & MODE_ALL))
- report_difference (¤t_stat_info, _("Mode differs"));
+ report_difference (¤t_stat_info, (quiet_option) ? NULL : _("Mode
differs"));
}
static int
diff -ur orig.003098/tar-1.19/src/create.c tar-1.19/src/create.c
--- orig.003098/tar-1.19/src/create.c 2007-10-05 19:46:49.000000000 +0200
+++ tar-1.19/src/create.c 2008-01-08 14:18:36.000000000 +0100
@@ -1734,12 +1734,12 @@
type = FIFOTYPE;
else if (S_ISSOCK (st->stat.st_mode))
{
- WARN ((0, 0, _("%s: socket ignored"), quotearg_colon (p)));
+ WARN1 ((0, 0, _("%s: socket ignored"), quotearg_colon (p)));
return;
}
else if (S_ISDOOR (st->stat.st_mode))
{
- WARN ((0, 0, _("%s: door ignored"), quotearg_colon (p)));
+ WARN1 ((0, 0, _("%s: door ignored"), quotearg_colon (p)));
return;
}
else
diff -ur orig.003098/tar-1.19/src/extract.c tar-1.19/src/extract.c
--- orig.003098/tar-1.19/src/extract.c 2007-08-26 10:56:55.000000000 +0200
+++ tar-1.19/src/extract.c 2008-01-08 14:18:36.000000000 +0100
@@ -195,7 +195,7 @@
check_time (char const *file_name, struct timespec t)
{
if (t.tv_sec <= 0)
- WARN ((0, 0, _("%s: implausibly old time stamp %s"),
+ WARN1 ((0, 0, _("%s: implausibly old time stamp %s"),
file_name, tartime (t, true)));
else if (timespec_cmp (volume_start_time, t) < 0)
{
@@ -212,7 +212,7 @@
diff.tv_nsec += BILLION;
diff.tv_sec--;
}
- WARN ((0, 0, _("%s: time stamp %s is %s s in the future"),
+ WARN1 ((0, 0, _("%s: time stamp %s is %s s in the future"),
file_name, tartime (t, true), code_timespec (diff, buf)));
}
}
diff -ur orig.003098/tar-1.19/src/tar.c tar-1.19/src/tar.c
--- orig.003098/tar-1.19/src/tar.c 2007-09-26 23:36:58.000000000 +0200
+++ tar-1.19/src/tar.c 2008-01-08 14:18:36.000000000 +0100
@@ -490,6 +490,8 @@
" directories until the end of extraction"), GRID+1 },
{"no-delay-directory-restore", NO_DELAY_DIRECTORY_RESTORE_OPTION, 0, 0,
N_("cancel the effect of --delay-directory-restore option"), GRID+1 },
+ {"quiet", 'Q', 0, 0,
+ N_("don't output warnings (2 levels)"), 31 },
#undef GRID
#define GRID 60
@@ -1389,6 +1391,10 @@
absolute_names_option = true;
break;
+ case 'Q':
+ quiet_option++;
+ break;
+
case 'r':
set_subcommand_option (APPEND_SUBCOMMAND);
break;