aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2019-03-27 13:34:59 -0500
committerRob Landley <rob@landley.net>2019-03-27 13:34:59 -0500
commit4eb39e1e3c9454635a8512b51931efe4ba2c14ed (patch)
treecc3693feb3b3a82ae2b29a98cf65925477192e1d /toys
parentbcb06e3244808e2ced0de2a39a348a7ddb7c54f2 (diff)
downloadtoybox-4eb39e1e3c9454635a8512b51931efe4ba2c14ed.tar.gz
Change fileunderdir() to return abspath to file.
Diffstat (limited to 'toys')
-rw-r--r--toys/posix/cp.c9
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;