Hello,

Small patch so ii will give usage information instead of running when
the user enters a wrong flag, doesn't supply an argument to a flag, or
supplies an argument without a flag.  It doesn't add any SLOC and
simplifies one.  Just happened to find out ii didn't handle incorrect
flags well when i tried 'ii -v' to get version information.

-emg
diff -r d93eaacde742 ii.c
--- a/ii.c	Fri Jun 25 10:55:05 2010 +0200
+++ b/ii.c	Tue Jul 20 16:27:17 2010 -0700
@@ -471,7 +471,6 @@
 	}
 	snprintf(nick, sizeof(nick), "%s", spw->pw_name);
 	snprintf(prefix, sizeof(prefix),"%s/irc", spw->pw_dir);
-	if (argc <= 1 || (argc == 2 && argv[1][0] == '-' && argv[1][1] == 'h')) usage();
 
 	for(i = 1; (i + 1 < argc) && (argv[i][0] == '-'); i++) {
 		switch (argv[i][1]) {
@@ -484,6 +483,9 @@
 			default: usage(); break;
 		}
 	}
+
+	if(i != argc) usage();
+
 	irc = tcpopen(port);
 	if(!snprintf(path, sizeof(path), "%s/%s", prefix, host)) {
 		fprintf(stderr, "%s", "ii: path to irc directory too long\n");

Reply via email to