summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--src/exec.c43
2 files changed, 13 insertions, 31 deletions
diff --git a/ChangeLog b/ChangeLog
index 8cfcc6a..7c49913 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@
 	* Removed CVS IDs and inclusion of sys/cdefs.h.
 	* Removed use of __P from error.h.
 	* Use bsd_signal if it exists and signal does not.
+	* Stop using sysexits.h in commandcmd.
 
 2005-10-26  Herbert Xu <herbert@gondor.apana.org.au>
 
diff --git a/src/exec.c b/src/exec.c
index c098eed..9b1a8bf 100644
--- a/src/exec.c
+++ b/src/exec.c
@@ -37,7 +37,6 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <stdlib.h>
-#include <sysexits.h>
 #include <paths.h>
 
 /*
@@ -847,41 +846,23 @@ commandcmd(argc, argv)
 	char **argv;
 {
 	int c;
-	int default_path = 0;
-	int verify_only = 0;
-	int verbose_verify_only = 0;
+	enum {
+		VERIFY_BRIEF = 1,
+		VERIFY_VERBOSE = 2,
+	} verify = 0;
 
 	while ((c = nextopt("pvV")) != '\0')
-		switch (c) {
-		default:
+		if (c == 'V')
+			verify |= VERIFY_VERBOSE;
+		else if (c == 'v')
+			verify |= VERIFY_BRIEF;
 #ifdef DEBUG
-			outfmt(out2,
-"command: nextopt returned character code 0%o\n", c);
-			return EX_SOFTWARE;
+		else if (c != 'p')
+			abort();
 #endif
-		case 'p':
-			default_path = 1;
-			break;
-		case 'v':
-			verify_only = 1;
-			break;
-		case 'V':
-			verbose_verify_only = 1;
-			break;
-		}
-
-	if (default_path + verify_only + verbose_verify_only > 1 ||
-	    !*argptr) {
-			outfmt(out2,
-"command [-p] command [arg ...]\n");
-			outfmt(out2,
-"command {-v|-V} command\n");
-			return EX_USAGE;
-	}
 
-	if (verify_only || verbose_verify_only) {
-		return describe_command(out1, *argptr, verbose_verify_only);
-	}
+	if (verify)
+		return describe_command(out1, *argptr, verify - VERIFY_BRIEF);
 
 	return 0;
 }