From 7b9488d8cf6fced3253560854bb85bcc8695aab0 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Mon, 30 Jun 2003 03:42:06 +0000 Subject: Make usage() take the exit val are an argument and have the -h flag use this to exit(0), not exit(1). Some configure/install sqcripts check for the existence of gzip by running "gzip -h" and checking the subshell's exit value. Noticed by naddy@ --- usr.bin/compress/compress.1 | 14 ++++++++------ usr.bin/compress/main.c | 19 ++++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) (limited to 'usr.bin/compress') diff --git a/usr.bin/compress/compress.1 b/usr.bin/compress/compress.1 index b5cc638f0a9..876883feabc 100644 --- a/usr.bin/compress/compress.1 +++ b/usr.bin/compress/compress.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: compress.1,v 1.19 2003/06/23 20:51:02 jmc Exp $ +.\" $OpenBSD: compress.1,v 1.20 2003/06/30 03:42:05 millert Exp $ .\" $NetBSD: compress.1,v 1.5 1995/03/26 09:44:34 glass Exp $ .\" .\" Copyright (c) 1986, 1990, 1993 @@ -47,31 +47,31 @@ .Nm compress .Op Fl LV .Nm compress -.Op Fl cdfgOqrtv123456789 +.Op Fl cdfghOqrtv123456789 .Op Fl b Ar bits .Op Fl S Ar suffix .Op Fl o Ar filename .Op Ar .Nm uncompress -.Op Fl cfqrtv +.Op Fl cfhqrtv .Op Fl o Ar filename .Op Ar .Pp .Nm gzip .Op Fl LV .Nm gzip -.Op Fl cdfgOqrtv123456789 +.Op Fl cdfghOqrtv123456789 .Op Fl b Ar bits .Op Fl S Ar suffix .Op Fl o Ar filename .Op Ar .Nm gunzip -.Op Fl cfqrtv +.Op Fl cfhqrtv .Op Fl o Ar filename .Op Ar .Pp .Nm zcat -.Op Fl fqr +.Op Fl fhqr .Op Ar .Sh DESCRIPTION The @@ -163,6 +163,8 @@ Use deflate scheme which reportedly provides better compression rates (force mode). This flag need not be specified when invoked as .Nm gzip . +.It Fl h +Print a short help message. .It Fl 1...9 Use deflate scheme with compression factor of .Fl 1 diff --git a/usr.bin/compress/main.c b/usr.bin/compress/main.c index 4aed26f0ffa..3c3c142aebc 100644 --- a/usr.bin/compress/main.c +++ b/usr.bin/compress/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.30 2003/06/29 21:14:37 millert Exp $ */ +/* $OpenBSD: main.c,v 1.31 2003/06/30 03:42:05 millert Exp $ */ static const char copyright[] = "@(#) Copyright (c) 1992, 1993\n\ @@ -35,7 +35,7 @@ static const char license[] = #if 0 static char sccsid[] = "@(#)compress.c 8.2 (Berkeley) 1/7/94"; #else -static const char main_rcsid[] = "$OpenBSD: main.c,v 1.30 2003/06/29 21:14:37 millert Exp $"; +static const char main_rcsid[] = "$OpenBSD: main.c,v 1.31 2003/06/30 03:42:05 millert Exp $"; #endif #endif /* not lint */ @@ -88,7 +88,7 @@ const struct compressor { int permission(const char *); void setfile(const char *, struct stat *); -void usage(void); +__dead void usage(int); int compress(const char *, const char *, const struct compressor *, int, struct stat *); int decompress(const char *, const char *, const struct compressor *, @@ -266,9 +266,10 @@ main(int argc, char *argv[]) break; case 'h': - case '?': + usage(0); + break; default: - usage(); + usage(1); } argc -= optind; argv += optind; @@ -620,11 +621,11 @@ permission(const char *fname) return (first == 'y'); } -void -usage(void) +__dead void +usage(int status) { fprintf(stderr, - "usage: %s [-cdfgOqrtvV] [-b bits] [-S suffix] [-[1-9]] [file ...]\n", + "usage: %s [-cdfghOqrtvV] [-b bits] [-S suffix] [-[1-9]] [file ...]\n", __progname); - exit(1); + exit(status); } -- cgit v1.2.3