Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Oct 2016 17:40:25 +0200
From:      David Demelier <demelier.david@gmail.com>
To:        Manish Jain <bourne.identity@hotmail.com>
Cc:        freebsd-questions <freebsd-questions@freebsd.org>
Subject:   Re: A request for cp flag
Message-ID:  <CAO%2BPfDf3n1JLjG7kq1CMzoHQm3WFAYumqxF2oxYM2%2B6153dpuQ@mail.gmail.com>
In-Reply-To: <VI1PR02MB0974F08FABD625DE9C2472B8F6D00@VI1PR02MB0974.eurprd02.prod.outlook.com>
References:  <VI1PR02MB0974F08FABD625DE9C2472B8F6D00@VI1PR02MB0974.eurprd02.prod.outlook.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Le 17 oct. 2016 4:50 PM, "Manish Jain" <bourne.identity@hotmail.com> a
=C3=A9crit :
> I occasionally face a problem while copying contents with cp. The -R
> flag of cp takes the source name as this : If the source_file ends in a
> /, the contents of the directory are copied rather than the directory
> itself.

This is by design, rsync does the same.

> Now, I am pretty sure, there must be good reasons for cp to behave in
> that manner by default. But it also creates significant opportunities
> for things to go wrong the way shell completion of directory names works.
>
> Could it considered a valid request that an extra flag (perhaps -r) be
> implemented that does the reverse : copy out src rather than src/* ?

This adds complexity, we will then need to explain carefully the difference
between the two options and then remember which of -r or -R copy the
directory itself and not the content.

And you can still get in trouble if typing too fast and accidentally write
cp -r instead of -R.

--=20
David Demelier



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAO%2BPfDf3n1JLjG7kq1CMzoHQm3WFAYumqxF2oxYM2%2B6153dpuQ>