aboutsummaryrefslogtreecommitdiff
path: root/toys/toysh.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-11-19 02:49:22 -0500
committerRob Landley <rob@landley.net>2006-11-19 02:49:22 -0500
commit8324b89598b2aee0957a0378f0f63ff5755498be (patch)
tree6958c34834147ab29607a8e67aca2b05a751f2ee /toys/toysh.c
parentb29ceb8bd0f99134fe215eebc531dbcd7717e8ae (diff)
downloadtoybox-8324b89598b2aee0957a0378f0f63ff5755498be.tar.gz
New option parsing infrastructure (doesn't use getopt). Hook it up to
existing applets. Still a bit buggy, but bits of it work.
Diffstat (limited to 'toys/toysh.c')
-rw-r--r--toys/toysh.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/toys/toysh.c b/toys/toysh.c
index 7ac430c9..074907ef 100644
--- a/toys/toysh.c
+++ b/toys/toysh.c
@@ -125,12 +125,15 @@ static void run_pipeline(struct pipeline *line)
tl = toy_find(cmd->argv[0]);
// Is this command a builtin that should run in this process?
if (tl && (tl->flags & TOYFLAG_NOFORK)) {
- struct toy_list *which = toys.which;
- char **argv = toys.argv;
+ struct toy_context temp;
+ // This fakes lots of what toybox_main() does.
+ memcpy(&temp, &toys, sizeof(struct toy_context));
+ bzero(&toys, sizeof(struct toy_context));
toy_init(tl, cmd->argv);
cmd->pid = tl->toy_main();
- toy_init(which, argv);
+ free(toys.optargs);
+ memcpy(&toys, &temp, sizeof(struct toy_context));
} else {
int status;
@@ -196,8 +199,10 @@ int toysh_main(void)
char *command=NULL;
FILE *f;
- // TODO get_optflags(argv, "c:", &command);
-
+ // Set up signal handlers and grab control of this tty.
+ if (CFG_TOYSH_TTY) {
+ if (isatty(0)) toys.optflags |= 1;
+ }
f = toys.argv[1] ? xfopen(toys.argv[1], "r") : NULL;
if (command) handle(command);
else {