From 92e8c1747852b40a8f393eae534695d47693739b Mon Sep 17 00:00:00 2001 From: ahgamut <41098605+ahgamut@users.noreply.github.com> Date: Thu, 21 Apr 2022 21:03:06 +0530 Subject: [PATCH] fix basename error with cp.com when the destination is a folder, cp.com should take the basename of the source file and add it to the destination. cp.c was instead using the basename function itself as a string (?), and not calling basename. --- examples/cp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/cp.c b/examples/cp.c index 6a657545e..254b30eab 100644 --- a/examples/cp.c +++ b/examples/cp.c @@ -73,7 +73,7 @@ void GetOpts(int argc, char *argv[]) { int cp(const char *src, const char *dst) { if (endswith(dst, "/") || isdirectory(dst)) { - dst = _gc(xasprintf("%s/%s", dst, basename)); + dst = _gc(xasprintf("%s/%s", dst, basename(src))); } if (!force && access(dst, W_OK) == -1 && errno != ENOENT) goto OnFail; if (copyfile(src, dst, flags) == -1) goto OnFail;