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.
This commit is contained in:
ahgamut 2022-04-21 21:03:06 +05:30
parent 9bfa6ec06e
commit 92e8c17478

View file

@ -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;