RE: Why does 'cp -f' not work anymore?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




-----Original Message-----
From: redhat-list-bounces@xxxxxxxxxx [mailto:redhat-list-bounces@xxxxxxxxxx]
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

-- 
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux