Date: Mon, 26 Apr 2010 20:57:31 +0300 From: Eitan Adler <eitanadlerlist@gmail.com> To: FreeBSD Hackers <freebsd-hackers@freebsd.org> Subject: [patch] [RFC] pathchk quiet flag Message-ID: <x2na0777e081004261057w6ede2592sdd4b0cddc43157f9@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
This path adds a -q flag to stop pathchk from outputting error messages but still return an error code. Index: pathchk.c =================================================================== --- pathchk.c (revision 207232) +++ pathchk.c (working copy) @@ -51,18 +51,20 @@ static void usage(void); static int pflag; /* Perform portability checks */ - -int +static int qflag = 0; /* stop pathchk from talking */ main(int argc, char *argv[]) { int ch, rval; const char *arg; - while ((ch = getopt(argc, argv, "p")) > 0) { + while ((ch = getopt(argc, argv, "pq")) > 0) { switch (ch) { case 'p': pflag = 1; break; + case 'q': + qflag = 1; + break; default: usage(); /*NOTREACHED*/ @@ -85,7 +87,7 @@ usage(void) { - fprintf(stderr, "usage: pathchk [-p] pathname ...\n"); + fprintf(stderr, "usage: pathchk [-qp] pathname ...\n"); exit(1); } @@ -118,20 +120,29 @@ *end = '\0'; if (namemax != -1 && complen > namemax) { - warnx("%s: %s: component too long (limit %ld)", path, - p, namemax); + if (!qflag) + { + warnx("%s: %s: component too long (limit %ld)", path, + p, namemax); + } goto bad; } if (!pflag && stat(pathd, &sb) == -1 && errno != ENOENT) { - warn("%s: %.*s", path, (int)(strlen(pathd) - - complen - 1), pathd); + if (!qflag) + { + warn("%s: %.*s", path, (int)(strlen(pathd) - + complen - 1), pathd); + } goto bad; } if (pflag && (badch = portable(p)) >= 0) { - warnx("%s: %s: component contains non-portable " - "character `%c'", path, p, badch); + if (!qflag) + { + warnx("%s: %s: component contains non-portable " + "character `%c'", path, p, badch); + } goto bad; } @@ -158,7 +169,10 @@ } else pathmax = _POSIX_PATH_MAX; if (pathmax != -1 && strlen(path) >= (size_t)pathmax) { - warnx("%s: path too long (limit %ld)", path, pathmax - 1); + if (!qflag) + { + warnx("%s: path too long (limit %ld)", path, pathmax - 1); + } goto bad; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?x2na0777e081004261057w6ede2592sdd4b0cddc43157f9>