我正在使用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版本,行为的差异是什么?请帮忙
答案 0 :(得分: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
程序无法找到它应该解压缩的文件时,它会退出并向其stdout发出0个字节。旧的tar
版本表现为0字节是正确的tar存档,因此没有错误消息。