From owner-freebsd-questions@freebsd.org Mon Oct 17 14:59:29 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 15855C157F5 for ; Mon, 17 Oct 2016 14:59:29 +0000 (UTC) (envelope-from matthew@FreeBSD.org) Received: from smtp.infracaninophile.co.uk (smtp.infracaninophile.co.uk [81.2.117.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.infracaninophile.co.uk", Issuer "infracaninophile.co.uk" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 9ACE7894 for ; Mon, 17 Oct 2016 14:59:28 +0000 (UTC) (envelope-from matthew@FreeBSD.org) Received: from zero-gravitas.local (unknown [85.199.232.226]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: m.seaman@infracaninophile.co.uk) by smtp.infracaninophile.co.uk (Postfix) with ESMTPSA id 4A5884AD6 for ; Mon, 17 Oct 2016 14:59:17 +0000 (UTC) Authentication-Results: smtp.infracaninophile.co.uk; dmarc=none header.from=FreeBSD.org Authentication-Results: smtp.infracaninophile.co.uk/4A5884AD6; dkim=none; dkim-atps=neutral Subject: Re: A request for cp flag To: freebsd-questions@freebsd.org References: From: Matthew Seaman Message-ID: <122eea3e-08a6-69a0-d67f-93873df095a6@FreeBSD.org> Date: Mon, 17 Oct 2016 15:59:10 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="hgm0Rl1hdahsGgmMcMEovrXSEMao9vHW4" X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on smtp.infracaninophile.co.uk X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Oct 2016 14:59:29 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --hgm0Rl1hdahsGgmMcMEovrXSEMao9vHW4 Content-Type: multipart/mixed; boundary="bKNFDd3KIEhbrTQSEI29wmwKBDl7hAoLT"; protected-headers="v1" From: Matthew Seaman To: freebsd-questions@freebsd.org Message-ID: <122eea3e-08a6-69a0-d67f-93873df095a6@FreeBSD.org> Subject: Re: A request for cp flag References: In-Reply-To: --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--