2012-04-12 32 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