[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-tar] gtar not handling stdout redirection correctly
From: |
Sergey Poznyakoff |
Subject: |
Re: [Bug-tar] gtar not handling stdout redirection correctly |
Date: |
Mon, 07 Nov 2005 00:45:32 EET |
Tuan Doan <address@hidden> wrote:
> If not redirecting stdout when creating the compressed tar file, I do not
> get the "trailing gargage ignored"
> message. Is it possible to have the return code to be 0?
Please try the attached patch.
Regards,
Sergey
Index: system.c
===================================================================
RCS file: /cvsroot/tar/tar/src/system.c,v
retrieving revision 1.14
diff -p -u -r1.14 system.c
--- system.c 17 Sep 2005 06:41:56 -0000 1.14
+++ system.c 6 Nov 2005 22:38:04 -0000
@@ -332,12 +332,10 @@ sys_child_open_for_compress (void)
xclose (parent_pipe[PWRITE]);
/* Check if we need a grandchild tar. This happens only if either:
- a) we are writing stdout: to force reblocking;
- b) the file is to be accessed by rmt: compressor doesn't know how;
- c) the file is not a plain file. */
+ a) the file is to be accessed by rmt: compressor doesn't know how;
+ b) the file is not a plain file. */
- if (strcmp (archive_name_array[0], "-") != 0
- && !_remdev (archive_name_array[0])
+ if (!_remdev (archive_name_array[0])
&& is_regular_file (archive_name_array[0]))
{
if (backup_option)
@@ -345,18 +343,20 @@ sys_child_open_for_compress (void)
/* We don't need a grandchild tar. Open the archive and launch the
compressor. */
-
- archive = creat (archive_name_array[0], MODE_RW);
- if (archive < 0)
+ if (strcmp (archive_name_array[0], "-"))
{
- int saved_errno = errno;
-
- if (backup_option)
- undo_last_backup ();
- errno = saved_errno;
- open_fatal (archive_name_array[0]);
+ archive = creat (archive_name_array[0], MODE_RW);
+ if (archive < 0)
+ {
+ int saved_errno = errno;
+
+ if (backup_option)
+ undo_last_backup ();
+ errno = saved_errno;
+ open_fatal (archive_name_array[0]);
+ }
+ xdup2 (archive, STDOUT_FILENO);
}
- xdup2 (archive, STDOUT_FILENO);
execlp (use_compress_program_option, use_compress_program_option,
(char *) 0);
exec_fatal (use_compress_program_option);