2

我正在使用 ksh

dummpy_file 不存在。查找 tar 的退出状态

SUSE10 / tar 版本 GNU 1.15.1

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

SUSE11 / tar 版本 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

不同的 tar 版本是否会导致行为差异?请帮忙

4

1 回答 1

4

是的,tar1.19修复了以下错误:

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."

gunzip管道开始处的程序找不到它应该解包的文件时,它会退出并向其标准输出发出 0 字节。旧tar版本的行为就像 0 字节是正确的 tar 存档一样,因此没有错误消息。

于 2012-04-12T09:34:58.533 回答