Module Name:    src
Committed By:   lukem
Date:           Sat Oct  9 09:07:21 UTC 2021

Modified Files:
        src/usr.bin/ftp: main.c

Log Message:
ftp: fix -? more portably

Start the optstring with ":" (which implicitly disables opterr),
and handle '?' with optopt=='?' separately to ':'.
Fixes -? display of full usage on other platforms.


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/usr.bin/ftp/main.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/ftp/main.c
diff -u src/usr.bin/ftp/main.c:1.127 src/usr.bin/ftp/main.c:1.128
--- src/usr.bin/ftp/main.c:1.127	Sat Jul 18 03:00:37 2020
+++ src/usr.bin/ftp/main.c	Sat Oct  9 09:07:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.127 2020/07/18 03:00:37 lukem Exp $	*/
+/*	$NetBSD: main.c,v 1.128 2021/10/09 09:07:20 lukem Exp $	*/
 
 /*-
  * Copyright (c) 1996-2015 The NetBSD Foundation, Inc.
@@ -98,7 +98,7 @@ __COPYRIGHT("@(#) Copyright (c) 1985, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.6 (Berkeley) 10/9/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.127 2020/07/18 03:00:37 lukem Exp $");
+__RCSID("$NetBSD: main.c,v 1.128 2021/10/09 09:07:20 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -267,7 +267,7 @@ main(int volatile argc, char **volatile 
 		}
 	}
 
-	while ((ch = getopt(argc, argv, "?46AadefginN:o:pP:q:r:Rs:tT:u:vVx:")) != -1) {
+	while ((ch = getopt(argc, argv, ":46AadefginN:o:pP:q:r:Rs:tT:u:vVx:")) != -1) {
 		switch (ch) {
 		case '4':
 			family = AF_INET;
@@ -420,6 +420,11 @@ main(int volatile argc, char **volatile 
 			if (optopt == '?') {
 				return usage_help();
 			}
+			warnx("-%c: unknown option", optopt);
+			return usage();
+
+		case ':':
+			warnx("-%c: missing argument", optopt);
 			return usage();
 
 		default:

Reply via email to