[hackers] [sbase] chown: return EXIT_FAILURE if one file failed. || Hiltjo Posthuma
commit 997f4f006caa784e6401d267aa2b04a1c0e63550
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Wed Apr 23 22:48:04 2014 +0200
chown: return EXIT_FAILURE if one file failed.
NOTE: coreutils chown wont process file series further on error, but busybox does. For consistency among the other tools follow busybox behaviour.
Signed-off-by: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
diff --git a/chown.c b/chown.c
index 245eb2e..bf37e65 100644
--- a/chown.c
+++ b/chown.c
_AT_@ -13,6 +13,7 @@ static void chownpwgr(const char *);
static bool rflag = false;
static struct passwd *pw = NULL;
static struct group *gr = NULL;
+static int ret = EXIT_SUCCESS;
static void
usage(void)
_AT_@ -62,15 +63,17 @@ main(int argc, char *argv[])
for(; argc > 0; argc--, argv++)
chownpwgr(argv[0]);
- return EXIT_SUCCESS;
+ return ret;
}
void
chownpwgr(const char *path)
{
if(chown(path, pw ? pw->pw_uid : (uid_t)-1,
- gr ? gr->gr_gid : (gid_t)-1) == -1)
+ gr ? gr->gr_gid : (gid_t)-1) == -1) {
weprintf("chown %s:", path);
+ ret = EXIT_FAILURE;
+ }
if(rflag)
recurse(path, chownpwgr);
}
Received on Thu Apr 24 2014 - 12:51:58 CEST
This archive was generated by hypermail 2.3.0
: Thu Apr 24 2014 - 13:00:17 CEST