I had bug in my bash script that created folder called
~
Anyway that lead me to another problem which is exscuting the following command:
rm -fr ~
ooopsss removed my home folder...
so my question is:
why rm works on the alias and not on the actual folder that is listed where I am?
You can reproduce it, by the following:
cd /tmp/
mkdir "~"
which rm ~
now you will see that the output of which rm ~ is pointing to the actual home folder and not the the ~ which was created in tmp
The ~
is expanded by the shell to the home directory name before rm
is called, the rm
program is unaware of it.
Expansion of magic characters like this can be suppressed by enclosing them in quotes:
$ echo ~
/Users/fredbloggs
$ echo '~'
~