Web lists-archives.com

Re: /bin/ gets deleted on error




On 2017-04-13 12:01, Dan Kegel wrote:
>>> For the second time this week my /bin/ folder gets obliterated on an
>>> error during normal usage. It is equivalent of doing the infamous "rm
>>> -rf  /bin" .
> 
> What were you doing immediately before the directory disappeared?
> 
> I have only had things like this happen from user error,
> e.g. scripting mistakes.
> 
> (The first time I saw somebody rm -rf / was in 1980 :-) )

BTDT a few times! 
Easy to do with a typo in a script variable name e.g. 
	rm -fR $fopdir/ 
or running a script with a typo that leaves a variable undefined; 
defensive coding is your friend to avoid disasters: 
	if [ -n "$foodir" ] && [ -d $foodir/ ]; then
	  /bin/rm -fR -- $foodir || exit
	else
	  echo "Can't find directory '$foodir'"
	  exit 2
	fi

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple