Question

I am using ksh

dummpy_file does not exist . Finding the exit status of tar

SUSE10 / tar version GNU 1.15.1

>gunzip -d dummpy_file | tar xvf -
gunzip : dummpy_file: No such file or directory
>echo $?
>0

SUSE11 / tar version GNU 1.20

>gunzip -d dummpy_file | tar xvf -
gunzip : dummpy_file No such file or directory   
tar : This does not look tar archive  
tar: Error exit delayed from previous errors  
>echo $?   
>2

Is the difference in behavior due the different tar versions ? Please help

Était-ce utile?

La solution

Yes, tar 1.19 fixed the following bug:

Recognition of broken archives.
When supplied an archive smaller than 512 bytes in reading mode (-x, -t), previous tar
versions silently ignored it, exiting with code 0. It is fixed. Tar now issues the
following diagnostic message: This does not look like a tar archive, and exits with code 2."

When the gunzip program at the start of pipeline can't find the file it's supposed to unpack, it exits and emits 0 bytes to its stdout. The old tar version behaved as if 0 bytes were a correct tar archive, hence no error message.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top