Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/ftp ftp: fix -? more portably
details: https://anonhg.NetBSD.org/src/rev/dbaf5ca58d89
branches: trunk
changeset: 988683:dbaf5ca58d89
user: lukem <lukem%NetBSD.org@localhost>
date: Sat Oct 09 09:07:20 2021 +0000
description:
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.
diffstat:
usr.bin/ftp/main.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diffs (39 lines):
diff -r 9234fe33a0b6 -r dbaf5ca58d89 usr.bin/ftp/main.c
--- a/usr.bin/ftp/main.c Sat Oct 09 09:06:28 2021 +0000
+++ b/usr.bin/ftp/main.c Sat Oct 09 09:07:20 2021 +0000
@@ -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 @@
#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 @@
}
}
- 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 @@
if (optopt == '?') {
return usage_help();
}
+ warnx("-%c: unknown option", optopt);
+ return usage();
+
+ case ':':
+ warnx("-%c: missing argument", optopt);
return usage();
default:
Home |
Main Index |
Thread Index |
Old Index