Hi, I've received interesting bug for tar. It's reported at https://bugzilla.redhat.com/show_bug.cgi?id=408621 . In short, tar -cvf /dev/stdout [files or dirs] > output.tar leads to corrupted archive. Tar is testing only for "-" when deciding if it should send listing to stdout or to stderr. I wrote patch which enables such handling also for /dev/stdout (it's attached).
So, is this behaviour known? Are users supposed to avoid this or should it be
fixed? I realize that the patch is not very clean as the absolute path is
platform dependent, but maybe there are other ways (e.g. somehow test if file
descriptor points to stdout).
Just wanted to know your opinion as from upstream developers (... and
hopefully get it fixed in upstream :))
Thanks,
--
Radek Brich
/__\ Base OS/core services
~~~~~~~~ Red Hat, Brno, Czech Rep.
diff -up tar-1.17/src/buffer.c.dev-stdout tar-1.17/src/buffer.c
--- tar-1.17/src/buffer.c.dev-stdout 2007-06-01 12:17:10.000000000 +0200
+++ tar-1.17/src/buffer.c 2007-12-10 18:04:19.000000000 +0100
@@ -486,7 +486,8 @@ _open_archive (enum access_mode wanted_a
if (!index_file_name
&& wanted_access == ACCESS_WRITE
- && strcmp (archive_name_array[0], "-") == 0)
+ && (strcmp (archive_name_array[0], "-") == 0
+ || strcmp (archive_name_array[0], "/dev/stdout") == 0))
stdlis = stderr;
}
else if (strcmp (archive_name_array[0], "-") == 0)
@@ -537,6 +538,8 @@ _open_archive (enum access_mode wanted_a
break;
case ACCESS_WRITE:
+ if (!index_file_name && strcmp (archive_name_array[0], "/dev/stdout") == 0)
+ stdlis = stderr;
if (backup_option)
{
maybe_backup_file (archive_name_array[0], 1);
signature.asc
Description: This is a digitally signed message part.
