aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-05-28 09:45:50 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-05-28 09:45:50 +0200
commitdd6b21192112711f1b7e89e998891f17f9c21c8d (patch)
tree7fbf5f40038db7375ca49da5f0a99ba5a3f61a34 /shell
parentb9f2bb36eaef9a3316fb7d54953a900b70912d85 (diff)
downloadbusybox-dd6b21192112711f1b7e89e998891f17f9c21c8d.tar.gz
hush: optimize type builtin a bit
function old new delta builtin_type 130 125 -5 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/hush.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/shell/hush.c b/shell/hush.c
index efa93c1a6..500091066 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -6766,32 +6766,31 @@ static int builtin_trap(char **argv)
/* http://www.opengroup.org/onlinepubs/9699919799/utilities/type.html */
static int builtin_type(char **argv)
{
- int i, ret = EXIT_SUCCESS;
+ int ret = EXIT_SUCCESS;
- for (i = 1; argv[i]; ++i) {
- void *path;
- const void *find_ret;
+ while (*++argv) {
+ char *path;
const char *type;
type = path = NULL;
if (0) {} /* make conditional compile easier below */
- /*else if ((find_ret = find_alias(argv[i])))
+ /*else if (find_alias(*argv))
type = "an alias";*/
#if ENABLE_HUSH_FUNCTIONS
- else if ((find_ret = find_function(argv[i])))
+ else if (find_function(*argv))
type = "a function";
#endif
- else if ((find_ret = find_builtin(argv[i])))
+ else if (find_builtin(*argv))
type = "a shell builtin";
- else if ((find_ret = path = find_in_path(argv[i])))
- type = find_ret;
+ else if ((path = find_in_path(*argv)) != NULL)
+ type = path;
if (!type) {
- bb_error_msg("type: %s: not found", argv[i]);
+ bb_error_msg("type: %s: not found", *argv);
ret = EXIT_FAILURE;
} else
- printf("%s is %s\n", argv[i], type);
+ printf("%s is %s\n", *argv, type);
if (path)
free(path);