Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Watch for undocumented behavior of cp -R' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Watch for undocumented behavior of cp -R
Authored by: Rogue.Monk on Nov 16, '05 08:17:29PM
Some say this is the way it should work. Others say they hate it this way.

If you don't like it you can always right a script to strip the trailing slash and then alias "cp -R" to it.

#this might need tweaking--was pieced together quickly
#Automator rocks for rapid shell script prototyping
for f in "$@"
	cp -R ${f%/}

Someone might want to tweak this further to ensure things like options are being passed down correctly.

The point is, Unix is designed to be tweaked. It gives you the most possible options and then lets you customize for your own needs.

Don't let it dictate how you use it.

[ Reply to This | # ]
Authored by: forman on Nov 16, '05 09:43:23PM

What he said. :)

[ Reply to This | # ]
Authored by: nickp on Nov 18, '05 09:12:10PM
After many years of sysadmin'ing, I ended up forsaking almost all such customizations, for the simple reason that I couldn't help out any of my users if I was too habituated to something nonstandard. Nor did I feel like running classes on 'suggested hacks for your initfiles'.

Jef Raskin, in his excellent The Humane Interface, goes into this whole area in more detail, but the short version is "if the system requires customization, then it is poorly designed."

In a similar vein, he argues against giving users (even expert users) multiple ways of getting the same thing done -- the cognitive overhead of figuring out which one to use is surprisingly large.

None of this is to argue that customizability, per se is evil, but that using it to paper over fundamental design flaws is. Some days un*x seems to me to be one huge design flaw ...

Raskin's book is available from Amazon.

[ Reply to This | # ]

Watch for undocumented behavior of cp -R
Authored by: pjungwir on Mar 22, '09 01:31:18PM

This is a nice workaround, but shouldn't the code be this?:


cp -R "${@%/}"

[ Reply to This | # ]