diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-05-20 13:08:31 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-05-20 13:08:31 +0000 |
commit | 46846e25a416464bac64939680628a2c0215b850 (patch) | |
tree | b85ca7e4e21b2495acf0775dbfa148a781819def /shell/ash.c | |
parent | 38ec147a181cc2b5d160d98ee20bb9aacc5de9eb (diff) | |
download | busybox-w32-46846e25a416464bac64939680628a2c0215b850.tar.gz busybox-w32-46846e25a416464bac64939680628a2c0215b850.tar.bz2 busybox-w32-46846e25a416464bac64939680628a2c0215b850.zip |
ash: implement type -p, costs less than 10 bytes
(patch by Mats Erik Andersson <mats.andersson64@comhem.se>)
Diffstat (limited to 'shell/ash.c')
-rw-r--r-- | shell/ash.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/shell/ash.c b/shell/ash.c index 4417ee908..ed46e1c0c 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -6892,14 +6892,8 @@ findkwd(const char *s) | |||
6892 | /* | 6892 | /* |
6893 | * Locate and print what a word is... | 6893 | * Locate and print what a word is... |
6894 | */ | 6894 | */ |
6895 | #if ENABLE_ASH_CMDCMD | ||
6896 | static int | 6895 | static int |
6897 | describe_command(char *command, int describe_command_verbose) | 6896 | describe_command(char *command, int describe_command_verbose) |
6898 | #else | ||
6899 | #define describe_command_verbose 1 | ||
6900 | static int | ||
6901 | describe_command(char *command) | ||
6902 | #endif | ||
6903 | { | 6897 | { |
6904 | struct cmdentry entry; | 6898 | struct cmdentry entry; |
6905 | struct tblentry *cmdp; | 6899 | struct tblentry *cmdp; |
@@ -6922,13 +6916,12 @@ describe_command(char *command) | |||
6922 | /* Then look at the aliases */ | 6916 | /* Then look at the aliases */ |
6923 | ap = lookupalias(command, 0); | 6917 | ap = lookupalias(command, 0); |
6924 | if (ap != NULL) { | 6918 | if (ap != NULL) { |
6925 | if (describe_command_verbose) { | 6919 | if (!describe_command_verbose) { |
6926 | out1fmt(" is an alias for %s", ap->val); | ||
6927 | } else { | ||
6928 | out1str("alias "); | 6920 | out1str("alias "); |
6929 | printalias(ap); | 6921 | printalias(ap); |
6930 | return 0; | 6922 | return 0; |
6931 | } | 6923 | } |
6924 | out1fmt(" is an alias for %s", ap->val); | ||
6932 | goto out; | 6925 | goto out; |
6933 | } | 6926 | } |
6934 | #endif | 6927 | #endif |
@@ -6997,15 +6990,17 @@ describe_command(char *command) | |||
6997 | static int | 6990 | static int |
6998 | typecmd(int argc, char **argv) | 6991 | typecmd(int argc, char **argv) |
6999 | { | 6992 | { |
7000 | int i; | 6993 | int i = 1; |
7001 | int err = 0; | 6994 | int err = 0; |
6995 | int verbose = 1; | ||
7002 | 6996 | ||
7003 | for (i = 1; i < argc; i++) { | 6997 | /* type -p ... ? (we don't bother checking for 'p') */ |
7004 | #if ENABLE_ASH_CMDCMD | 6998 | if (argv[1][0] == '-') { |
7005 | err |= describe_command(argv[i], 1); | 6999 | i++; |
7006 | #else | 7000 | verbose = 0; |
7007 | err |= describe_command(argv[i]); | 7001 | } |
7008 | #endif | 7002 | while (i < argc) { |
7003 | err |= describe_command(argv[i++], verbose); | ||
7009 | } | 7004 | } |
7010 | return err; | 7005 | return err; |
7011 | } | 7006 | } |