On 22/09/13 01:24 AM, Pulkit Bhuwalka wrote:
>
> Hi,
>
> This is to report an issue that I have run into while using tar.
>
> _Issue_ - tar destroys file when arguments are passed in wrong order
> leading to loss of data.
>
> _Correct tar order_ - tar -cvzf "archive_file_name" "file_to_be_archived"
>
> _Order actually passed_ - tar - cvzf "file_to_be_archived"
> "archive_file_name"
>
> tar ignores the fact that the "file_to_be_archived" exists and simply
> overwrites it, and then crashes out complaining that
> "archive_file_name" doesn't exist.
>
> While I agree that the command was passed by the user in the wrong
> order, I feel it's something that is quite possible and tar should
> follow a defensive approach of complaining that a file exists rather
> than overwriting it.
It looks like open_archive() will succeed for archives that already
exist. Even if you're using "create" and not "append". There must be a
reason for this. However, there seems to be an easy solution.

Instead of calling open_archive() in create_archive(), we could do a
one-time call to it in dump_file() after at least one
"file_to_be_archived" has been found to exist. There is already an error
"Cowardly refusing to create an empty archive" that is given when no
members are specified on the command line. The above would be an
extension of this to when no *existent* members are specified on the
command line.
>
> I've been using tar for years and I ended up passing the wrong
> arguments today, which led to me losing data :-(
>
> Thanks,
> Pulkit and Meghna
>


-- 
Sent from my Macbook Wheel
<http://www.theonion.com/video/apple-introduces-revolutionary-new-laptop-with-no,14299/>

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to