summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-10-29 12:25:03 +0000
committerJim Meyering <jim@meyering.net>2000-10-29 12:25:03 +0000
commit78abfe5da3580d4e5581e515de48574eb9c2c492 (patch)
tree0cd54b04b1d6d606be4cdabbf97b0a0762de6fd1 /src
parentffb5b5a2ad654ced0d251fcd50369ca198eae0d1 (diff)
downloadcoreutils-78abfe5da3580d4e5581e515de48574eb9c2c492.tar.xz
(do_copy): When constructing dst_path for use with the
--parents option, first remove any trailing slashes from the command line argument. Otherwise, tests/cp/cp-parent would fail on NetBSD.
Diffstat (limited to 'src')
-rw-r--r--src/cp.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/cp.c b/src/cp.c
index 70cd36ce3..9db7c5f67 100644
--- a/src/cp.c
+++ b/src/cp.c
@@ -518,13 +518,26 @@ do_copy (int n_files, char **file, const char *target_directory,
char *arg_in_concat = NULL;
char *arg = file[i];
+ /* Trailing slashes are meaningful (i.e., maybe worth preserving)
+ only in the source file names. */
if (remove_trailing_slashes)
strip_trailing_slashes (arg);
if (flag_path)
{
- /* Append all of `arg' to `dest'. */
- dst_path = path_concat (dest, arg, &arg_in_concat);
+ char *arg_no_trailing_slash;
+
+ /* Use `arg' without trailing slashes in constructing destination
+ file names. Otherwise, we can end up trying to create a
+ directory via `mkdir ("dst/foo/"...', which is not portable.
+ It fails, due to the trailing slash, on at least
+ NetBSD 1.[34] systems. */
+ ASSIGN_STRDUPA (arg_no_trailing_slash, arg);
+ strip_trailing_slashes (arg_no_trailing_slash);
+
+ /* Append all of `arg' (minus any trailing slash) to `dest'. */
+ dst_path = path_concat (dest, arg_no_trailing_slash,
+ &arg_in_concat);
if (dst_path == NULL)
xalloc_die ();