[hackers] [sbase] cp: Don't try to open the file twice in case we did not provide -f || sin

From: <git_AT_suckless.org>
Date: Mon, 05 May 2014 16:06:26 +0200

commit b257f7a05f24d218ab37aa43d22e0d19a88bd33b
Author: sin <sin_AT_2f30.org>
Date: Mon May 5 15:02:16 2014 +0100

    cp: Don't try to open the file twice in case we did not provide -f

diff --git a/util/cp.c b/util/cp.c
index 471a89b..33853ad 100644
--- a/util/cp.c
+++ b/util/cp.c
_AT_@ -64,10 +64,13 @@ cp(const char *s1, const char *s2)
                 eprintf("fopen %s:", s1);
 
         if(!(f2 = fopen(s2, "w"))) {
- if (cp_fflag == true)
+ if (cp_fflag == true) {
                         unlink(s2);
- if (!(f2 = fopen(s2, "w")))
+ if (!(f2 = fopen(s2, "w")))
+ eprintf("fopen %s:", s2);
+ } else {
                         eprintf("fopen %s:", s2);
+ }
         }
 
         concat(f1, s1, f2, s2);
Received on Mon May 05 2014 - 16:06:26 CEST

This archive was generated by hypermail 2.3.0 : Mon May 05 2014 - 16:12:09 CEST