From 71f9a7a93571ed5b367bc6b2782a3545d8ca1614 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Wed, 16 Dec 2020 16:07:41 -0500 Subject: Take username as a required positional argument --- notemap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'notemap.c') diff --git a/notemap.c b/notemap.c index e2b41dc..a1d280c 100644 --- a/notemap.c +++ b/notemap.c @@ -167,7 +167,7 @@ int main(int argc, char *argv[]) { int rppFlags = 0; int opt; - while (0 < (opt = getopt(argc, argv, "M:afh:m:p:u:vw"))) { + while (0 < (opt = getopt(argc, argv, "M:afh:m:p:vw"))) { switch (opt) { break; case 'M': mailbox = optarg; break; case 'a': add = true; @@ -181,10 +181,11 @@ int main(int argc, char *argv[]) { break; default: return EX_USAGE; } } - if (!user) errx(EX_USAGE, "username required"); + if (optind < argc) user = argv[optind++]; argv += optind; argc -= optind; + if (!user) errx(EX_USAGE, "username required"); if (!host) { host = strchr(user, '@'); if (!host) errx(EX_USAGE, "no domain in username"); -- cgit 1.4.1