sh scripting -- escape * character?
rm -rf * is a dangerous command.
Believe me.
I use it several times a day in the course of development. Once or twice it's bitten me pretty badly... usually with accidentally executed commands from the history while I'm trying to work past the abilities of my current caffeine intake.
Onto the problem.
rm -ri * is no good, because I don't want to push 'y' all day.
I was thinking of aliasing rm to a shell script that parses the arguments. If it sees '-rf *' as an arg, it simply asks 'Are you sure?', and waits for a yes or no answer.
I can't seem to escape the * character. I've tried \*, \042. Various mixes of quotes. I'm actually thinking this is futile now, for if I print the arguments the script is fed, it's a list of all the files in the directory.
Another option is do the confirmation whenever it see -rf. This might annoy me though, as I frequently delete directories this way and haven't shot myself in the foot with it.
Yet.
Is there some other way to make a slightly less interactive rm -r *?
|