From 982e3044a5e1f77cadd16d5adca999173c5bb42a Mon Sep 17 00:00:00 2001 From: Herbert Xu Date: Sat, 29 Oct 2005 14:03:32 +1000 Subject: [BUILTIN] Stop using sysexits.h in commandcmd This gets rid of the only reference of sysexits.h in dash which is from commandcmd. This is needed for klibc support since it doesn't have sysexits.h. The only uses of sysexits.h in commandcmd is superfluous anyway. In fact, it is overly sensitive about usages such as 'command -vV ls'. By making its behaviour close to that of bash/ksh, we end up saving a bit of space too. --- src/exec.c | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-) (limited to 'src/exec.c') 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 #include #include -#include #include /* @@ -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; } -- cgit 1.4.1