GNU bug report logs -
#32751
split does not break on error from tar
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 32751 in the body.
You can then email your comments to 32751 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#32751
; Package
coreutils
.
(Mon, 17 Sep 2018 14:53:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Alexander Fieroch <alexander.fieroch <at> mpi-dortmund.mpg.de>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Mon, 17 Sep 2018 14:53:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
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.
Thanks!
----
Ubuntu 18.04.1
tar 1.29b
coreutils 8.28
----
Best regards,
Alexander
[smime.p7s (application/pkcs7-signature, attachment)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#32751
; Package
coreutils
.
(Mon, 17 Sep 2018 19:11:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 32751 <at> debbugs.gnu.org (full text, mbox):
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
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#32751
; Package
coreutils
.
(Tue, 18 Sep 2018 08:00:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 32751 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
> 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
Thanks Rainer, that is a very good hint and is working for me!
But why is this not a bug? In what case is it useful to ignore a
non-zero exit code in a pipeline?
Thanks!
Best regards,
Alexander
[smime.p7s (application/pkcs7-signature, attachment)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#32751
; Package
coreutils
.
(Tue, 18 Sep 2018 08:07:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 32751 <at> debbugs.gnu.org (full text, mbox):
tag 32751 notabug
close 32751
stop
On 18/09/18 00:59, Alexander Fieroch wrote:
>> 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
>
> Thanks Rainer, that is a very good hint and is working for me!
> But why is this not a bug? In what case is it useful to ignore a
> non-zero exit code in a pipeline?
Well that's been the shell behavior since the beginning,
and lot's of scripts depend on that,
and so it can't be changed.
As for split, it just sees the end of input
and exits without error.
thanks,
Pádraig
Added tag(s) notabug.
Request was from
Pádraig Brady <P <at> draigBrady.com>
to
control <at> debbugs.gnu.org
.
(Tue, 18 Sep 2018 08:07:03 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
32751 <at> debbugs.gnu.org and Alexander Fieroch <alexander.fieroch <at> mpi-dortmund.mpg.de>
Request was from
Pádraig Brady <P <at> draigBrady.com>
to
control <at> debbugs.gnu.org
.
(Tue, 18 Sep 2018 08:07:04 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Tue, 16 Oct 2018 11:24:04 GMT)
Full text and
rfc822 format available.
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.