Archive Utility does not extract all files from tar archive
2
votes
0
answers
111
views
Archive Utility vs BSD tar behaviour:
echo -n 'Hello' >hello.txt # "Hello" in hello.txt
tar cvf hello.tar hello.txt # hello.tar contains "hello.txt" file with "hello" text
echo ' world!' >>hello.txt # "Hello world!" in hello.txt
tar rf hello.tar hello.txt # hello.tar contains 2 versions of "hello.txt" file a first with "Hello" text and second with "Hello world!\n" text
tar tvf hello.tar # to confirm!
rm hello.txt # hello.txt removal
tar xvf hello.tar # tar extracts the two hello.txt files, i.e. the first then the second overwriting the first
cat hello.txt # "Hello world!" expected
One-liner:
echo -n 'hello' >hello.txt; tar cvf hello.tar hello.txt; echo ' world!' >>hello.txt; tar rf hello.tar hello.txt; tar tvf hello.tar; rm hello.txt ; tar xvf hello.tar; cat hello.txt
Same behaviour with both BSD tar and GNU tar
As "tar" stands for Tape ARchiver ... it is historically meaningful to provide the option to physically append a corrected file to the archive on recorded on the tape without requiring to completely erase the tape first ...
Question: Now try to extract hello.tar with MacOS "Archive Utility" and you have only hello.txt with "Hello" ... why!?
So to my point of view, "Archive Utility" does not extract all files ...
-/-
Bonus question: And if "hello.txt" already exists in the folder, "Archive Utility" will extract the first file as "hello 2.txt" without even requesting which action the user wants (i.e. a rename or an overwrite) ... why!?
Asked by Frédéric
(121 rep)
May 8, 2023, 01:00 PM