Why does 'cp -f' not work anymore?

Cameron Simpson cs at zip.com.au
Thu Nov 3 04:01:17 UTC 2005


On 02Nov2005 11:04, Chris W. Parker <cparker at swatgear.com> wrote:
| Cameron Simpson <mailto:cs at zip.com.au>
|     on Tuesday, November 01, 2005 4:32 PM said:
| > Even easier is to quote just one character instead of the whole word:
| >   \cp -f newfile.txt this-has-to-go.txt
| 
| I've sinced just changed the original alias to be only 'cp' (although I
| guess I might as well get rid of the alias altogether...).

That'd what I do.

| But what I'm finding now is that it's not confirming an overwrite at all
| now.

Nice, isn't it?

| Originally the problem was that even 'cp -f' resulted in an overwrite
| confirmation. What I want to happen is that 'cp' will ask me for
| permission to overwrite and 'cp -f' will not. Is that possible?

No, unless you write another alias or shell function yourself.

| Or do I
| just have to remember to type 'cp -i'?

Yes.

| Am I making sense?

For some definition of the term, yes.
How about this:

	# just in case - ick!
	unalias cp

	# define smarter wrapper
	cp()
	{ [ "x$1" = x-f ] || set -- -i ${1+"$@"}
	  command cp "$@"
	}

This should turn on -i mode if you don't supply a -f.

Cheers,
--
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

The code was willing,
It considered your request,
But the chips were weak.
- Haiku Error Messages http://www.salonmagazine.com/21st/chal/1998/02/10chal2.html




More information about the redhat-list mailing list