diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2005-10-29 14:03:32 +1000 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2005-10-29 14:15:36 +1000 |
commit | 982e3044a5e1f77cadd16d5adca999173c5bb42a (patch) | |
tree | c3a91c0673d63551173c1e7d349ff0db2e4e2ce4 | |
parent | [SIGNAL] Use bsd_signal if it exists and signal does not (diff) | |
download | dash-982e3044a5e1f77cadd16d5adca999173c5bb42a.tar.gz dash-982e3044a5e1f77cadd16d5adca999173c5bb42a.zip |
[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.
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | src/exec.c | 43 |
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; } |