aboutsummaryrefslogtreecommitdiff
path: root/toys/toysh.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2007-11-29 18:14:37 -0600
committerRob Landley <rob@landley.net>2007-11-29 18:14:37 -0600
commitefda21ca931766eed6cfc49d1b2122c53827d9fc (patch)
tree16453d708a1b0fc6b325ada99bbe72cbaab7148b /toys/toysh.c
parent7634b55f27ad483ec634ba9defac93872e3a329f (diff)
downloadtoybox-efda21ca931766eed6cfc49d1b2122c53827d9fc.tar.gz
Change command main() functions to return void, and exit(toys.exitval) from
the toybox infrastructure instead. Eliminates a return call from each command.
Diffstat (limited to 'toys/toysh.c')
-rw-r--r--toys/toysh.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/toys/toysh.c b/toys/toysh.c
index 18a3dce4..dbb187fa 100644
--- a/toys/toysh.c
+++ b/toys/toysh.c
@@ -133,7 +133,8 @@ static void run_pipeline(struct pipeline *line)
memcpy(&temp, &toys, sizeof(struct toy_context));
bzero(&toys, sizeof(struct toy_context));
toy_init(tl, cmd->argv);
- cmd->pid = tl->toy_main();
+ tl->toy_main();
+ cmd->pid = toys.exitval;
free(toys.optargs);
memcpy(&toys, &temp, sizeof(struct toy_context));
} else {
@@ -184,19 +185,18 @@ static void handle(char *command)
}
}
-int cd_main(void)
+void cd_main(void)
{
char *dest = *toys.optargs ? *toys.optargs : getenv("HOME");
if (chdir(dest)) error_exit("chdir %s",dest);
- return 0;
}
-int exit_main(void)
+void exit_main(void)
{
exit(*toys.optargs ? atoi(*toys.optargs) : 0);
}
-int toysh_main(void)
+void toysh_main(void)
{
FILE *f;
@@ -210,12 +210,12 @@ int toysh_main(void)
size_t cmdlen = 0;
for (;;) {
char *command = 0;
- if (!f) putchar('$');
+ if (!f) xputc('$');
if (1 > getline(&command, &cmdlen, f ? : stdin)) break;
handle(command);
free(command);
}
}
- return 1;
+ toys.exitval = 1;
}