cp: print error to stderr and continue

This commit is contained in:
Hiltjo Posthuma 2014-08-02 14:40:04 +00:00 committed by sin
parent a9c9681f95
commit 0cbafaecb6

View File

@ -105,16 +105,24 @@ cp(const char *s1, const char *s2)
} }
} }
if(!(f1 = fopen(s1, "r"))) if(!(f1 = fopen(s1, "r"))) {
eprintf("fopen %s:", s1); weprintf("fopen %s:", s1);
cp_status = EXIT_FAILURE;
return 0;
}
if(!(f2 = fopen(s2, "w"))) { if(!(f2 = fopen(s2, "w"))) {
if (cp_fflag == true) { if (cp_fflag == true) {
unlink(s2); unlink(s2);
if(!(f2 = fopen(s2, "w"))) if(!(f2 = fopen(s2, "w"))) {
eprintf("fopen %s:", s2); weprintf("fopen %s:", s2);
cp_status = EXIT_FAILURE;
return 0;
}
} else { } else {
eprintf("fopen %s:", s2); weprintf("fopen %s:", s2);
cp_status = EXIT_FAILURE;
return 0;
} }
} }
concat(f1, s1, f2, s2); concat(f1, s1, f2, s2);