rm -rf $Home (was GNOME hangs)

Les Mikesell lesmikesell at gmail.com
Mon Aug 7 03:26:45 UTC 2006


On Sun, 2006-08-06 at 13:55, Kwan Lowe wrote:

> Actually as the above command is written, it would have deleted everything under /,
> not /root. $Home is not set, but $HOME.
> 
> I've seen some scripts with the following:
> 
> LOGDIR=/var/log/myapp
> cd $LOGDIR
> rm -rf *
> 
> If for some reason LOGDIR is inaccessible then the script owners $HOME is likely to
> be trashed. On some systems where root's home is not /root, then likely everything
> in / gets trashed.

Long, long ago (circa SysVr2) the bourne shell would exit when
in a non-interactive script and a cd failed.  It was a good
idea but I guess it was too complicated to always get the
script vs. interactive part right.   Now you need to
write
cd /path || exit 
if it doesn't make sense to continue.

-- 
  Les Mikesell
   lesmikesell at gmail.com





More information about the fedora-list mailing list