logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/
commit: 69a02d048eb0b0bfb253e8db1c2b6611f260a85c
parent 1b6301ea49cfc12272182aab88d5a93b9bf5ce03
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Mon, 17 Mar 2025 19:54:26 +0100

cmd/getconf: continue after errors for -a

Diffstat:

Mcmd/getconf.c21++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/cmd/getconf.c b/cmd/getconf.c @@ -155,6 +155,7 @@ main(int argc, char *argv[]) } else if(o_all && argc == 0) { + int err = 0; char *buf = NULL; size_t buflen = 0; for(size_t i = 0; i < (sizeof(confstr_vars) / sizeof(*confstr_vars)); i++) @@ -171,7 +172,8 @@ main(int argc, char *argv[]) confstr_vars[i].name, strerror(errno)); free(buf); - return 1; + err = 1; + continue; } /* undefined */ @@ -190,7 +192,8 @@ main(int argc, char *argv[]) buflen, strerror(errno)); free(buf); - return 1; + err = 1; + continue; } buflen = buflen_ret; buf = buf_ret; @@ -209,7 +212,8 @@ main(int argc, char *argv[]) buflen, strerror(errno)); free(buf); - return 1; + err = 1; + continue; } /* undefined */ @@ -235,7 +239,8 @@ main(int argc, char *argv[]) confstr_vars[i].value, confstr_vars[i].name, strerror(errno)); - return 1; + err = 1; + continue; } if(ret == -1) ret = sysconf_vars[i].limit_h; @@ -264,7 +269,7 @@ main(int argc, char *argv[]) printf("%s = %ld\n", limits_vars[i].name, ret); } - return 0; + return err; } else if(!o_all && argc == 2) { @@ -295,6 +300,7 @@ main(int argc, char *argv[]) } else if(o_all && argc == 1) { + int err = 0; for(size_t i = 0; i < (sizeof(pathconf_vars) / sizeof(*pathconf_vars)); i++) { errno = 0; @@ -307,14 +313,15 @@ main(int argc, char *argv[]) pathconf_vars[i].value, pathconf_vars[i].name, strerror(errno)); - return 1; + err = 1; + continue; } if(ret == -1) ret = sysconf_vars[i].limit_h; printf("%s = %ld\n", pathconf_vars[i].name, ret); } - return 0; + return err; } else {