Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Oct 2016 15:59:10 +0100
From:      Matthew Seaman <matthew@FreeBSD.org>
To:        freebsd-questions@freebsd.org
Subject:   Re: A request for cp flag
Message-ID:  <122eea3e-08a6-69a0-d67f-93873df095a6@FreeBSD.org>
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
This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--hgm0Rl1hdahsGgmMcMEovrXSEMao9vHW4
Content-Type: multipart/mixed; boundary="bKNFDd3KIEhbrTQSEI29wmwKBDl7hAoLT";
 protected-headers="v1"
From: Matthew Seaman <matthew@FreeBSD.org>
To: freebsd-questions@freebsd.org
Message-ID: <122eea3e-08a6-69a0-d67f-93873df095a6@FreeBSD.org>
Subject: Re: A request for cp flag
References: <VI1PR02MB0974F08FABD625DE9C2472B8F6D00@VI1PR02MB0974.eurprd02.prod.outlook.com>
In-Reply-To: <VI1PR02MB0974F08FABD625DE9C2472B8F6D00@VI1PR02MB0974.eurprd02.prod.outlook.com>

--bKNFDd3KIEhbrTQSEI29wmwKBDl7hAoLT
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

On 2016/10/17 15:50, Manish Jain wrote:
> I am using FreeBSD 10.3 amd64 with bash as the login shell.
>=20
> I occasionally face a problem while copying contents with cp. The -R=20
> flag of cp takes the source name as this : If the source_file ends in a=
=20
> /, the contents of the directory are copied rather than the directory=20
> itself.
>=20
> Now, I am pretty sure, there must be good reasons for cp to behave in=20
> that manner by default. But it also creates significant opportunities=20
> for things to go wrong the way shell completion of directory names work=
s.
>=20
> Could it considered a valid request that an extra flag (perhaps -r) be =

> implemented that does the reverse : copy out src rather than src/* ?

You're not going to get anyone to change the behaviour of a core command
like cp(1) I'm afraid.  For all that you dislike the behaviour when
copying a directory path that ends in '/' there will be many, many more
people that have written scripts that depend on that exact behaviour and
will be exceedingly peeved if those scripts stop working.

However, as you say: you're using bash.  You can define a shell function
'cp' which is a wrapper around the original cp(1) and that strips any
trailing '/' characters from command arguments.

	Cheers,

	Matthew



--bKNFDd3KIEhbrTQSEI29wmwKBDl7hAoLT--

--hgm0Rl1hdahsGgmMcMEovrXSEMao9vHW4
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - https://gpgtools.org

iQJ8BAEBCgBmBQJYBOdEXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQxOUYxNTRFQ0JGMTEyRTUwNTQ0RTNGMzAw
MDUxM0YxMEUwQTlFNEU3AAoJEABRPxDgqeTnfy8P+wQ35XmNWsNOdfwLyuCPFZYv
+qtpx6dkF6fvurCRYNH18mnhapU4dPHzjTDbuaOxuuFXfyCeTwRkoM63+JV0YsB7
7GrxcxKo3EKpXy03nrm42kjqEHMzXVYoY+WUvaPSMfkieWaMicOYvFPtKvKI/9tO
oU1THPAAZIb7RvX7o7Hzdgv25V5e6q25BmX103gvz+OPHlquw4G5aWFeYT+fLDbt
3BIOB8S/T54YlyiXLpvk2GtpaHSenxiSk2xnrkil7cZxnqDlnX9IJSpIHDN18Vov
rrpbOLQW1gEaTcY9kowCLtliUMtmz9fXN6YgbySX8CzX8gIrinJsWTad54i+GN9R
BokL6ybU6gkZ33NMuhjYVEpqdBAFYkfJMRe+k1RRvtmWhrco3U6namusA1AJVAaY
7eanOg3drU/O3nlGMv92AWbsGHwX8U67reDyGV44gx/FWSSHg21ObsE1HCHVI7VK
0iBZp6fSoE22351jBVYEGHkh1+wXb7bJLpR99VTvnyCtaRybLKeb/1Kj47f5VJ4w
RI9zSOKPGJ415q4gkOCuARu+d1ThpepIzUOZvark96ZVjxZ3S2D66USz9Eqejhfb
7A3GjWOeWxR01o6XqJsJBE+R8WHsTgSiOsBxKXkKqwZNZLaaANxUBDLA5yze6p9X
AUz7Nts03djmdMTwkgc0
=W4Ec
-----END PGP SIGNATURE-----

--hgm0Rl1hdahsGgmMcMEovrXSEMao9vHW4--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?122eea3e-08a6-69a0-d67f-93873df095a6>