%
% > "36) What is wrong with having '.' in your $PATH"
%
% >Seriously, I'd be interested to hear of some horror stories where
% >something * (that's * with a capital N not a typo (hell of
% >a typo though!)) has happened. I'd post this to comp.unix but it's
% >been getting a little boring lately.
%
% Yesterday I wrote a file named /tmp/ls. It looks something like
% this:
[* script deleted]
%
% ps: I didn't really set that home directory land mine. But this
% Man-Wei Tam guy diserves it.
Nobody 'deserves' it until s/he's had a chance to learn and failed. To
wit:
This really did happen to me... When I was just getting root access,
it was illustrated to me how . can be dangerous via the following
little script:
#!/bin/sh
/usr/bin/mkdir $HOME/...
mv $HOME/.??* $HOME/... 2>/dev/null
mv $HOME/* $HOME/... 2>/dev/null
/usr/bin/ls $*
Needless to say, this is undamaging but a little unnerving; it could
just as well have been 'rm -rf $HOME'.
The funny thing is that I left this in my home directory after having
been shown it, and our SysAdmin, for some reason, executed an ls while
in my home directory. In his path, he has . (as do I, though I put it
last... Helps for building stuff :-) listed, and my version of ls got
executed. I came in the next day to a find a letter proclaiming 'That
was NOT an appropriate use of the root account!' in my email... I, of
course, was baffled until I saw the ls in my directory... tee hee
Anyway, there's a real-life story for you. It can happen. If you do
wish to have . in your path, make sure it's the very last thing there.
A better solution would be to edit your local path information and put
the desired path somewhere in there, but I know that that can be
inconvenient. A still better solution is to not have . in your path,
provide root with aliases going to 'the real things' instead of letting
the path search for them, and not use root anyway unless you really
need it then. One fellow on campus didn't bother to create himself a
user-level account; he always did everything as root. Dangerous way to
live...
%
% --
% ........................................................ Phil McCalley
Happy computing...
:-D
--
"I think, therefore I am wrong." -- me