2012-04-12 36 views
1

我正在使用ksh焦油混乱退出状态

dummpy_file不存在。寻找焦油

SUSE10 /焦油GNU版本1.15.1

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

SUSE11 /焦油版本的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 

是由于不同焦油版本的行为差异的退出状态?请帮助

+0

你有什么版本的ksh和gunzip? – choroba 2012-04-12 09:21:21

回答

1

是,tar 1.19 fixed以下错误:

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归档文件,因此没有错误消息。

+0

我尝试了相同的测试,现在不是不存在的文件,而是使用了大约1MB的文本文件,并将其重命名为abc.tar.gz,以便解除绑定失败。现在也是gunzip -d abc.tar.gz | tar xvf - gunzip:abc.tar.gz:不是gzip格式> echo $?在tar版本1.15中给出0。请告诉我这个bug是否也在1.19中修复? – 2012-04-12 10:31:27

+0

是的,这是一回事。重要的是第一个程序不会向标准输出输出任何内容(错误消息转到标准错误流,这是单独的)。 – 2012-04-12 10:40:21