From e76aeac3cc39b404ece0f4258ed378cd74379bcd Mon Sep 17 00:00:00 2001 From: Jarno Mäkipää Date: Sat, 15 Feb 2020 13:31:48 +0200 Subject: cp: fix -D (--parents) (REWORK MINIMAL FIX) add: test for -D fix: b/c/d/FILE not copying into a/ with -D option dirname() is not needed when handling FLAG(D) since filename under src or dest should not be changed. github.com/landley/toybox/issues/165 --- toys/posix/cp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'toys/posix') diff --git a/toys/posix/cp.c b/toys/posix/cp.c index f70c0501..06f1ff92 100644 --- a/toys/posix/cp.c +++ b/toys/posix/cp.c @@ -407,7 +407,7 @@ void cp_main(void) if (*--trail == '/') *trail = 0; if (destdir) { - char *s = FLAG(D) ? dirname(src) : getbasename(src); + char *s = FLAG(D) ? src : getbasename(src); TT.destname = xmprintf("%s/%s", destname, s); if (FLAG(D)) { -- cgit v1.2.3