diff options
Diffstat (limited to 'toys')
-rw-r--r-- | toys/posix/cp.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/toys/posix/cp.c b/toys/posix/cp.c index 3b30f8a8..751a718c 100644 --- a/toys/posix/cp.c +++ b/toys/posix/cp.c @@ -409,12 +409,15 @@ void cp_main(void) char *s = (toys.optflags&FLAG_D) ? getdirname(src) : getbasename(src); TT.destname = xmprintf("%s/%s", destname, s); - if (toys.optflags&FLAG_D) { + if (FLAG(D)) { free(s); - if (!fileunderdir(TT.destname, destname)) { + if (!(s = fileunderdir(TT.destname, destname))) { error_msg("%s not under %s", TT.destname, destname); continue; - } else mkpath(TT.destname); + } + // TODO: .. follows abspath, not links... + free(s); + mkpath(TT.destname); } } else TT.destname = destname; |