[dev] [sbase] [PATCH 2/2] ln: exit non-zero when errors accured

From: Eivind Uggedal <eivind_AT_uggedal.com>
Date: Fri, 8 May 2015 08:16:58 +0000

---
 ln.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/ln.c b/ln.c
index 2bfdbbdeacc6..bbda8215716f 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;
 }
-- 
2.4.0
Received on Fri May 08 2015 - 10:16:58 CEST

This archive was generated by hypermail 2.3.0 : Fri May 08 2015 - 10:24:17 CEST