[hackers] [sbase] cp: print error to stderr and continue || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Sat, 02 Aug 2014 14:46:04 +0200

commit 0cbafaecb68a5977f99e00f4a084686193e1d5e1
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Sat Aug 2 14:40:04 2014 +0000

    cp: print error to stderr and continue

diff --git a/util/cp.c b/util/cp.c
index eace1e7..030dfab 100644
--- a/util/cp.c
+++ b/util/cp.c
_AT_@ -105,16 +105,24 @@ cp(const char *s1, const char *s2)
                 }
         }
 
- if(!(f1 = fopen(s1, "r")))
- eprintf("fopen %s:", s1);
+ if(!(f1 = fopen(s1, "r"))) {
+ weprintf("fopen %s:", s1);
+ cp_status = EXIT_FAILURE;
+ return 0;
+ }
 
         if(!(f2 = fopen(s2, "w"))) {
                 if (cp_fflag == true) {
                         unlink(s2);
- if(!(f2 = fopen(s2, "w")))
- eprintf("fopen %s:", s2);
+ if(!(f2 = fopen(s2, "w"))) {
+ weprintf("fopen %s:", s2);
+ cp_status = EXIT_FAILURE;
+ return 0;
+ }
                 } else {
- eprintf("fopen %s:", s2);
+ weprintf("fopen %s:", s2);
+ cp_status = EXIT_FAILURE;
+ return 0;
                 }
         }
         concat(f1, s1, f2, s2);
Received on Sat Aug 02 2014 - 14:46:04 CEST

This archive was generated by hypermail 2.3.0 : Sat Aug 02 2014 - 14:48:15 CEST