[hackers] [sbase] ln: exit non-zero when errors accured || Eivind Uggedal

From: <git_AT_suckless.org>
Date: Fri, 8 May 2015 11:07:03 +0200 (CEST)

commit f5f43dbd5b577bae6ea80f52675c91c063df0548
Author: Eivind Uggedal <eivind_AT_uggedal.com>
Date: Fri May 8 08:16:58 2015 +0000

    ln: exit non-zero when errors accured

diff --git a/ln.c b/ln.c
index 2bfdbbd..bbda821 100644
--- a/ln.c
+++ b/ln.c
_AT_@ -19,7 +19,8 @@ int
 main(int argc, char *argv[])
 {
         char *fname, *to;
- int sflag = 0, fflag = 0, hasto = 0, dirfd = AT_FDCWD, flags = AT_SYMLINK_FOLLOW;
+ int sflag = 0, fflag = 0, hasto = 0, dirfd = AT_FDCWD, ret = 0,
+ flags = AT_SYMLINK_FOLLOW;
         struct stat st, tost;
 
         ARGBEGIN {
_AT_@ -64,12 +65,14 @@ main(int argc, char *argv[])
                 if (!sflag) {
                         if (stat(*argv, &st) < 0) {
                                 weprintf("stat %s:", *argv);
+ ret = 1;
                                 continue;
                         } else if (fstatat(dirfd, to, &tost, AT_SYMLINK_NOFOLLOW) < 0) {
                                 if (errno != ENOENT)
                                         eprintf("stat %s:", to);
                         } else if (st.st_dev == tost.st_dev && st.st_ino == tost.st_ino) {
                                 weprintf("%s and %s are the same file\n", *argv, *argv);
+ ret = 1;
                                 continue;
                         }
                 }
_AT_@ -78,8 +81,9 @@ main(int argc, char *argv[])
                 if ((!sflag ? linkat(AT_FDCWD, *argv, dirfd, to, flags)
                             : symlinkat(*argv, dirfd, to)) < 0) {
                         weprintf("%s %s <- %s:", fname, *argv, to);
+ ret = 1;
                 }
         }
 
- return 0;
+ return ret;
 }
Received on Fri May 08 2015 - 11:07:03 CEST

This archive was generated by hypermail 2.3.0 : Fri May 08 2015 - 11:12:15 CEST