From 8324b89598b2aee0957a0378f0f63ff5755498be Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 19 Nov 2006 02:49:22 -0500 Subject: New option parsing infrastructure (doesn't use getopt). Hook it up to existing applets. Still a bit buggy, but bits of it work. --- toys/toysh.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'toys/toysh.c') 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 { -- cgit v1.2.3