aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorlandley <landley@driftwood>2006-10-18 18:38:16 -0400
committerlandley <landley@driftwood>2006-10-18 18:38:16 -0400
commitcd9dfc3b7b73715840b63180e2e4bfdb6e7ca9a4 (patch)
treea4e4932ecc15140ed48761ca8d32d5a0edc53bf7 /main.c
parent4f344e356d2c36c4b1df46917eaef25f82ca79a9 (diff)
downloadtoybox-cd9dfc3b7b73715840b63180e2e4bfdb6e7ca9a4.tar.gz
Next drop of toysh, plus more infratructure.
Diffstat (limited to 'main.c')
-rw-r--r--main.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/main.c b/main.c
index 90d80c78..57fb7f4e 100644
--- a/main.c
+++ b/main.c
@@ -17,6 +17,7 @@ struct toy_list toy_list[] = {
{"cd", cd_main, TOYFLAG_NOFORK},
{"df", df_main, TOYFLAG_USR|TOYFLAG_SBIN},
{"exit", exit_main, TOYFLAG_NOFORK},
+ {"sh", toysh_main, TOYFLAG_BIN},
{"toysh", toysh_main, TOYFLAG_BIN}
};
@@ -51,6 +52,16 @@ struct toy_list *toy_find(char *name)
}
}
+void toy_init(struct toy_list *which, char *argv[])
+{
+ // Free old toys contents here?
+
+ toys.which = which;
+ toys.argv = argv;
+ for (toys.argc = 0; argv[toys.argc]; toys.argc++);
+ toys.exitval = 1;
+}
+
// Run a toy.
void toy_exec(char *argv[])
{
@@ -59,12 +70,7 @@ void toy_exec(char *argv[])
which = toy_find(argv[0]);
if (!which) return;
- // Free old toys contents here?
-
- toys.which = which;
- toys.argv = argv;
- for (toys.argc = 0; argv[toys.argc]; toys.argc++);
- toys.exitval = 1;
+ toy_init(which, argv);
exit(toys.which->toy_main());
}