This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]