Mercurial > hg > toybox
comparison main.c @ 1501:c51a4dbe5db7 draft
Don't segfault for --help of single.sh build of OLDTOY commands that use another command's help.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 27 Sep 2014 19:58:18 -0500 |
parents | 74b29c369420 |
children | 3c77af6f81cc |
comparison
equal
deleted
inserted
replaced
1500:cf77c4939385 | 1501:c51a4dbe5db7 |
---|---|
23 char toybuf[4096], libbuf[4096]; | 23 char toybuf[4096], libbuf[4096]; |
24 | 24 |
25 struct toy_list *toy_find(char *name) | 25 struct toy_list *toy_find(char *name) |
26 { | 26 { |
27 int top, bottom, middle; | 27 int top, bottom, middle; |
28 | |
29 if (!CFG_TOYBOX) return 0; | |
28 | 30 |
29 // If the name starts with "toybox" accept that as a match. Otherwise | 31 // If the name starts with "toybox" accept that as a match. Otherwise |
30 // skip the first entry, which is out of order. | 32 // skip the first entry, which is out of order. |
31 | 33 |
32 if (!strncmp(name,"toybox",6)) return toy_list; | 34 if (!strncmp(name,"toybox",6)) return toy_list; |
67 toys.argv = argv; | 69 toys.argv = argv; |
68 | 70 |
69 if (CFG_TOYBOX_I18N) setlocale(LC_ALL, "C"+!!(which->flags & TOYFLAG_LOCALE)); | 71 if (CFG_TOYBOX_I18N) setlocale(LC_ALL, "C"+!!(which->flags & TOYFLAG_LOCALE)); |
70 | 72 |
71 if (CFG_TOYBOX_HELP_DASHDASH && argv[1] && !strcmp(argv[1], "--help")) { | 73 if (CFG_TOYBOX_HELP_DASHDASH && argv[1] && !strcmp(argv[1], "--help")) { |
72 if (toys.which == toy_list && toys.argv[2]) | 74 if (CFG_TOYBOX && toys.which == toy_list && toys.argv[2]) |
73 if (!(toys.which = toy_find(toys.argv[2]))) return; | 75 if (!(toys.which = toy_find(toys.argv[2]))) return; |
74 show_help(); | 76 show_help(); |
75 xexit(); | 77 xexit(); |
76 } | 78 } |
77 | 79 |