GNU bug report logs - #32751
split does not break on error from tar

Previous Next

Package: coreutils;

Reported by: Alexander Fieroch <alexander.fieroch <at> mpi-dortmund.mpg.de>

Date: Mon, 17 Sep 2018 14:53:02 UTC

Severity: normal

Tags: notabug

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 32751 <at> debbugs.gnu.org (full text, mbox):

From: "Rainer M. Canavan" <coreutils <at> canavan.de>
To: alexander.fieroch <at> mpi-dortmund.mpg.de
Cc: 32751 <at> debbugs.gnu.org
Subject: Re: bug#32751: split does not break on error from tar
Date: Mon, 17 Sep 2018 21:10:31 +0200 (CEST)
Alexander Fieroch <alexander.fieroch <at> mpi-dortmund.mpg.de> wrote:
> Hi all,
> 
> I found a bug in "split".
> I want to tar some files but some of them have wrong permissions. tar 
> puts out an exit code 2 "Cannot open: Permission denied". That is good 
> because in my script I can catch this error and react to this.
> 
> $ tar -c -f /tmp/test.tar -C /media/testpath testfile ; echo $?
> tar: testfile: Cannot open: Permission denied
> tar: Exiting with failure status due to previous errors
> 2
> 
> Unfortunately my tar directory is too big to save it in one file on my 
> filesystem that I have to split the archive but doing this "split" does 
> not get the error code 2 from tar and does not break as it should:
> 
> $ tar -c -f - -C /media/testpath testfile | split - ; echo $?
> tar: testfile: Cannot open: Permission denied
> tar: Exiting with failure status due to previous errors
> 0
> 
> In the end I got a tar file without files that have no permissions and 
> my script does not break because of error code 0.


As far as I can tell, this is not a bug, but the way pipelines work, 
i.e. the  result of a pipeline (here the combination of tar and 
split) is the result of the last command in the pipeline. If you 
want the combination to fail if tar fails, you can use e.g. 
set -o pipefail in bash or read PIPESTATUS. For other shells,
see e.g. http://cfajohnson.com/shell/cus-faq-2.html#Q11


Rainer




This bug report was last modified 6 years and 253 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.