I have some PHP code I’m moving from a development directory to the webserver directory on OS X (Snow leopard).
I noticed something quirky I didn’t understand with cp. I wrote a deployment script and noticed that when I run:
sudo cp -rf phpfun "/Library/Webserver/Documents/phpfun"
The command runs without an issue, but doesn’t overwrite the files inside of the directory (namely index.php).
But if I run:
sudo cp -rf phpfun "/Library/Webserver/Documents/"
Everything is written as expected. What’s the deal here? What is cp doing in the first case?
In the first case, it’s copying the
phpfundirectory inside of/Library/Webserver/Documents/phpfun, meaning you end up with/Library/Webserver/Documents/phpfun/phpfun. Probably not what you want.The
cp(1)man page has all of the information you might need about what’s going on and why.