Mercurial > hg > toybox
diff toys/toysh.c @ 121:933766b0bd4b
Allow applets with optarg string NULL to use toy.optargs[].
author | Rob Landley <rob@landley.net> |
---|---|
date | Fri, 01 Jun 2007 13:41:24 -0400 |
parents | 19b5567f0a1b |
children | 99e651512aa4 |
line wrap: on
line diff
--- a/toys/toysh.c Fri Jun 01 11:46:56 2007 -0400 +++ b/toys/toysh.c Fri Jun 01 13:41:24 2007 -0400 @@ -184,14 +184,14 @@ int cd_main(void) { - char *dest = toys.argv[1] ? toys.argv[1]: getenv("HOME"); + char *dest = *toys.optargs ? *toys.optargs : getenv("HOME"); if (chdir(dest)) error_exit("chdir %s",dest); return 0; } int exit_main(void) { - exit(toys.argv[1] ? atoi(toys.argv[1]) : 0); + exit(*toys.optargs ? atoi(*toys.optargs) : 0); } int toysh_main(void) @@ -203,7 +203,7 @@ if (CFG_TOYSH_TTY) { if (isatty(0)) toys.optflags |= 1; } - f = toys.argv[1] ? xfopen(toys.argv[1], "r") : NULL; + f = *toys.optargs ? xfopen(*toys.optargs, "r") : NULL; if (command) handle(command); else { unsigned cmdlen=0;