mirror of
https://github.com/sheumann/hush.git
synced 2024-12-22 14:30:31 +00:00
hush: unify handling of builtin applets
Saves about 10 bytes for each additional builtin applet. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
This commit is contained in:
parent
db67a20595
commit
ccb1959aa5
16
shell/hush.c
16
shell/hush.c
@ -6897,24 +6897,24 @@ static int FAST_FUNC builtin_true(char **argv UNUSED_PARAM)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int FAST_FUNC builtin_test(char **argv)
|
||||
static int FAST_FUNC _builtin_applet(char **argv, int (applet)(int argc, char **argv))
|
||||
{
|
||||
int argc = 0;
|
||||
while (*argv) {
|
||||
argc++;
|
||||
argv++;
|
||||
}
|
||||
return test_main(argc, argv - argc);
|
||||
return applet(argc, argv - argc);
|
||||
}
|
||||
|
||||
static int FAST_FUNC builtin_test(char **argv)
|
||||
{
|
||||
return _builtin_applet(argv, test_main);
|
||||
}
|
||||
|
||||
static int FAST_FUNC builtin_echo(char **argv)
|
||||
{
|
||||
int argc = 0;
|
||||
while (*argv) {
|
||||
argc++;
|
||||
argv++;
|
||||
}
|
||||
return echo_main(argc, argv - argc);
|
||||
return _builtin_applet(argv, echo_main);
|
||||
}
|
||||
|
||||
static int FAST_FUNC builtin_eval(char **argv)
|
||||
|
Loading…
Reference in New Issue
Block a user