Why does 'cp -f' not work anymore?

Michael Velez mikev777 at hotmail.com
Thu Nov 3 12:19:29 UTC 2005



-----Original Message-----
From: redhat-list-bounces at redhat.com [mailto:redhat-list-bounces at redhat.com]
On Behalf Of Cameron Simpson
Sent: Wednesday, November 02, 2005 11:01 PM
To: General Red Hat Linux discussion list
Subject: Re: Why does 'cp -f' not work anymore?

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,
--

Hope you don't mind.  I liked your function and decided to use it and
changed it to be more in line with cp syntax.

cp()
{
	[ $((`expr " $*" : '.* -[a-zA-Z]*f[a-zA-Z]* .*'`)) -ne 0 ] || 
	[ $((`expr " $*" : '.* --force .*'`)) -ne 0 ] || 
	set -- -i ${1+"$@"}
	command cp "$@"
}

This function checks for --force and -f anywhere on the command line, as
well as it allows options to be combined with -f, such as -rfv.

I've done simple testing.  Works for me.

If anybody sees an inconsistency, please let me know.

Michael




More information about the redhat-list mailing list