Discussion:
df(1) - use return, not exit() in main()
Michal Mazurek
2016-02-01 18:23:41 UTC
Permalink
Replace exit() with return.

Index: df.c
===================================================================
RCS file: /cvs/src/bin/df/df.c,v
retrieving revision 1.54
diff -u -p -r1.54 df.c
--- df.c 9 Oct 2015 01:37:06 -0000 1.54
+++ df.c 1 Feb 2016 17:58:59 -0000
@@ -178,7 +178,7 @@ main(int argc, char *argv[])
bsdprint(mntbuf, mntsize, maxwidth);
}

- exit(mntsize ? 0 : 1);
+ return mntsize ? 0 : 1;
}

char *


But perhaps the logic is incorrect:
$ df -t nfs
$ echo $?
1
Is an empty list an error? GNU df returns 1 with an error message "df:
no file systems processed". NetBSD returns 0, but only because it
doesn't have this commit.

Commit 1.39 "Don't print header if we didn't print any usage lines."
contained the change:

- exit(0);
+ exit(mntsize ? 0 : 1);
--
Michal Mazurek
Loading...