There is a bug with exit code in bzip2-0.9.5d-2 (Redhat 6.2) Create a small file AA (4 bytes), and try to tar it to the tape /dev/st1 which does not exists. tar prints error message (as it should be), but exits with the code 0, what is incorrect. It looks like bzip does not catch non-zero exit code of tar. echo AAA >AA tar Icvf /dev/st1 AA tar (grandchild): /dev/st1: Cannot open: No such device tar (grandchild): Error is not recoverable: exiting now but the exit code of tar is 0. This is incorrect. But when you do tar without bizp2 compression tar cvf /dev/st1 AA tar exits with error code 2 as it should be. Looks like a bug in bzip2 program. Similar bug was in gzip program. I was telled it was fixed in gzip 1.3.
I get error code 2 with bzip2 as well: [root@hoser /root]# tar zcvf /dev/st1 AAA tar: AAA: Cannot stat: No such file or directory tar: Error exit delayed from previous errors [root@hoser /root]# tar (grandchild): /dev/st1: Cannot open: No such device tar (grandchild): Error is not recoverable: exiting now [root@hoser /root]# echo $? 2 [root@hoser /root]# tar Icvf /dev/st1 AAA tar: AAA: Cannot stat: No such file or directory tar (grandchild): /dev/st1: Cannot open: No such device tar (grandchild): Error is not recoverable: exiting now tar: Error exit delayed from previous errors [root@hoser /root]# echo $? 2 [root@hoser /root]# tar cvf /dev/st1 AAA tar: /dev/st1: Cannot open: No such device tar: Error is not recoverable: exiting now [root@hoser /root]# echo $? 2 [root@hoser /root]# I use bzip2 1.0, which is in Rawhide
I tried these packages from Rewhide rpm -q tar gzip tar-1.13.17-4 gzip-1.3-3 on RedHat 6.2 It does not work. The error code is 0. 1.create a file AAA (you did not create a file in your example) echo AAA >/tmp/AAA 2. tar it to unexisting tape. [root@localhost /tmp]# tar zcvf /dev/st1 /tmp/AAA tar: Removing leading `/'' from member names tmp/AAA tar (grandchild): /dev/st1: Cannot open: No such device tar (grandchild): Error is not recoverable: exiting now [root@localhost /tmp]# echo $? 0 [root@localhost /tmp]# See, error code is 0. In the same time without a compression [root@localhost /tmp]# tar cvf /dev/st1 /tmp/AAA tar: /dev/st1: Cannot open: No such device tar: Error is not recoverable: exiting now [root@localhost /tmp]# echo $? 2 [root@localhost /tmp]# See, error code with compression is 0, without compression is 2. something does not work.