Module Name: src Committed By: martin Date: Sun Mar 10 19:05:46 UTC 2024
Modified Files: src/usr.bin/getconf [netbsd-8]: getconf.1 getconf.c Log Message: Pull up following revision(s) (requested by riastradh in ticket #1943): usr.bin/getconf/getconf.c: revision 1.37 usr.bin/getconf/getconf.1: revision 1.14 PR/57875: Jason Bacon: Try again without an _ for portability. getconf.1: Note that leading underscores in configuration variable names are ignored by getconf(1). While here, add a section with examples, and make the synopsis more concise. PR bin/57875 To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.13.16.1 src/usr.bin/getconf/getconf.1 cvs rdiff -u -r1.35 -r1.35.18.1 src/usr.bin/getconf/getconf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/getconf/getconf.1 diff -u src/usr.bin/getconf/getconf.1:1.13 src/usr.bin/getconf/getconf.1:1.13.16.1 --- src/usr.bin/getconf/getconf.1:1.13 Sun Apr 13 01:45:34 2014 +++ src/usr.bin/getconf/getconf.1 Sun Mar 10 19:05:46 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: getconf.1,v 1.13 2014/04/13 01:45:34 snj Exp $ +.\" $NetBSD: getconf.1,v 1.13.16.1 2024/03/10 19:05:46 martin Exp $ .\" .\" Copyright (c) 1996 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd August 9, 2011 +.Dd February 18, 2024 .Dt GETCONF 1 .Os .Sh NAME @@ -37,13 +37,10 @@ .Nm .Ar system_var .Nm -.Fl a -.Nm .Ar path_var .Ar pathname .Nm -.Fl a -.Ar pathname +.Fl a Op Ar pathname .Sh DESCRIPTION The .Nm @@ -80,8 +77,28 @@ standard output, in the format = .Va value .Dc . +.Pp +For compatibility with other operating systems, +.Nm +will ignore leading underscores in the names specified in the +.Ar system_var +and +.Ar path_var +arguments. .Sh EXIT STATUS .Ex -std +.Sh EXAMPLES +To retrieve the number of configured processors, use: +.Bd -literal -offset indent +$ getconf NPROCESSORS_CONF +.Ed +.Pp +To retrieve the maximum number of bytes (excluding the trailing +.Dv NUL ) +for a filename in the current directory, use: +.Bd -literal -offset indent +$ getconf NAME_MAX . +.Ed .Sh SEE ALSO .Xr pathconf 2 , .Xr confstr 3 , Index: src/usr.bin/getconf/getconf.c diff -u src/usr.bin/getconf/getconf.c:1.35 src/usr.bin/getconf/getconf.c:1.35.18.1 --- src/usr.bin/getconf/getconf.c:1.35 Thu Dec 19 19:11:50 2013 +++ src/usr.bin/getconf/getconf.c Sun Mar 10 19:05:46 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: getconf.c,v 1.35 2013/12/19 19:11:50 rmind Exp $ */ +/* $NetBSD: getconf.c,v 1.35.18.1 2024/03/10 19:05:46 martin Exp $ */ /*- * Copyright (c) 1996, 1998 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: getconf.c,v 1.35 2013/12/19 19:11:50 rmind Exp $"); +__RCSID("$NetBSD: getconf.c,v 1.35.18.1 2024/03/10 19:05:46 martin Exp $"); #endif /* not lint */ #include <err.h> @@ -193,7 +193,7 @@ main(int argc, char **argv) { int ch; const struct conf_variable *cp; - const char *varname, *pathname; + const char *varname, *pathname, *vn; int found; setprogname(argv[0]); @@ -226,8 +226,10 @@ main(int argc, char **argv) pathname = argv[0]; /* may be NULL */ found = 0; + vn = varname; +again: for (cp = conf_table; cp->name != NULL; cp++) { - if (a_flag || strcmp(varname, cp->name) == 0) { + if (a_flag || strcmp(vn, cp->name) == 0) { /*LINTED weird expression*/ if ((cp->type == PATHCONF) == (pathname != NULL)) { printvar(cp, pathname); @@ -238,8 +240,11 @@ main(int argc, char **argv) } } - if (!a_flag && !found) + if (!a_flag && !found) { + if (*vn++ == '_') + goto again; errx(EXIT_FAILURE, "%s: unknown variable", varname); + } (void)fflush(stdout); return ferror(stdout) ? EXIT_FAILURE : EXIT_SUCCESS;