Click to See Complete Forum and Search --> : Watch out with 'source' (the command)


Uranus
12-02-2004, 03:43 PM
I just wanted to say that you should be careful when sourcing stuff - for an /etc/profile or .bash_profile it is ok, but basically it's just executing a file without needing a +x flag (like sh, but you use it more often).
I had kind of an accident today:
I finally finished installing LFS in a way that I really liked (was like my 5th time in 5 days, every time I either messed up or wasn't satisfied by the way I set it up), so I started to configure some general stuff (starting with the console). I wanted to write a .bash_profile for root containing some aliases, so I did. However, I saved it in the current dir (not the home dir). I don't know why, but after that I ran the source command from the home dir, using tab completion. What happened, I pressed tab and enter too fast after each other and my .bash_history was sourced. This totally ruined by system. I guess I can call myself lucky that the system was only a day old, if it happened on a totally configured, older system that would have been worse.
Maybe it's kind of ironical to put it in 'How I did it', but I didn't know where else to put it :)
I just wanted to make clear that 'rm -rf / home/user/dir' isn't the only way to fsck up.
Sam