Re: tar command dangerously written

From: Bruce Barnett (spamhater113+U050522074529_at_grymoire.com)
Date: 05/22/05


Date: 22 May 2005 11:45:32 GMT

bonomi@host122.r-bonomi.com (Robert Bonomi) writes:

> Doing _that_ is *REALLY* dangerous.

Agreed. That's why I mentioned using capital letters:
        Cp instead of cp
        Tar instead of tar.
But it's still common practice.

> Should "newfs' ask about *every* file it is about to clobber, before doing
> it's thing?

I would think that sysadmin commands would not normally be executed by
users who wish to be extra safe.

> Who should catch "rm -fr foo /*" when "rm -fr foo/*" was intended?

It would be easy to write a wrapper that counts the number of
arguments and notices the -r option, and notices the -f option, and
prompts for a confirmation.

        Warning: if you type yes, the system will delete 5,407 files and 24 directories. Are you sure you want to continue [Yes/no]:

> *What*happens* when a 'command' is added to the system that the shell DOES NOT
> KNOW about?

I am not saying that each and every command had to have a safe mode.
But if there was a standard mechanism that could be used, utilities
could check this and behave differently if they want to.

For instance, there could be a "SAFETY_MODE" environment variable.
Or, as I said, a different directory.

>>Or, as I mentioned, someone can create friendly wrappers, and collect
>>them in a ~/friendly/bin directory. Users can start out with it first
>>in the searchpath, and remove it when they need to.
>
> Have you ever seen "training wheels" on a unicycle?

Training wheels exist for cp/mv/rm and some shells.

-- 
Sending unsolicited commercial e-mail to this account incurs a fee of 
$500 per message, and acknowledges the legality of this contract.