If you attempt to selectively extract files from an archive, and it is listed 
more than once, then you get a very misleading error message. It wasn’t super 
obvious that a file was listed twice when I first encountered the problem since 
I was using wildcards but I believe that goes through shell expansion so 
obviously nothing to do with tar on that end.

$ ls
test.sh

$ cat test.sh
set -x

touch testFile
tar -tf test.tar.gz
tar -czvf test.tar.gz testFile
tar -xz -f test.tar.gz testFile
tar -xz -f test.tar.gz testFile testFile


$ ./test.sh
++ touch testFile
++ tar -czvf test.tar.gz testFile
testFile
++ tar -tf test.tar.gz
testFile
++ tar -xz -f test.tar.gz testFile
++ tar -xz -f test.tar.gz testFile testFile
tar: testFile: Not found in archive
tar: Exiting with failure status due to previous errors

You can see that I create a file, then archive it, then confirm it’s in the 
archive, then selectively extract it with the file only listed once and it 
works fine, but if I listed the file twice, it fails with:
“tar: testFile: Not found in archive”

I downloaded the latest tar source from a mirror and built it to see if it’s 
present in the latest release:

$ tar --version
tar (GNU tar) 1.32
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.

I don’t mind if you think this should be an error in the first place, but the 
misleading error message is the worst part of it. Perhaps there’s an internal 
reason for this, but I figured I would report it.

Thanks,
Ryan


Reply via email to