mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-04-21 22:34:51 +00:00
Fix basename error with cp.com (#389)
This commit is contained in:
parent
9d61e23c80
commit
01b25e267b
1 changed files with 2 additions and 2 deletions
|
@ -73,14 +73,14 @@ void GetOpts(int argc, char *argv[]) {
|
||||||
|
|
||||||
int cp(const char *src, const char *dst) {
|
int cp(const char *src, const char *dst) {
|
||||||
if (endswith(dst, "/") || isdirectory(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 (!force && access(dst, W_OK) == -1 && errno != ENOENT) goto OnFail;
|
||||||
if (copyfile(src, dst, flags) == -1) goto OnFail;
|
if (copyfile(src, dst, flags) == -1) goto OnFail;
|
||||||
return 0;
|
return 0;
|
||||||
OnFail:
|
OnFail:
|
||||||
fprintf(stderr, "%s %s %s: %s\n", "error: cp", src, dst, strerror(errno));
|
fprintf(stderr, "%s %s %s: %s\n", "error: cp", src, dst, strerror(errno));
|
||||||
return 1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue