diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/args.c | 2 | ||||
-rw-r--r-- | lib/lib.c | 12 | ||||
-rw-r--r-- | lib/lib.h | 1 |
3 files changed, 8 insertions, 7 deletions
@@ -133,6 +133,7 @@ void get_optflags(void) long *nextarg = (long *)&toy; char *options = toys.which->options; + if (CFG_HELP) toys.exithelp++; // Allocate memory for optargs maxargs = 0; while (toys.argv[maxargs++]); @@ -300,6 +301,7 @@ notflag: error_exit("Need %d argument%s", minargs, minargs ? "s" : ""); if (optarg>maxargs) error_exit("Max %d argument%s", maxargs, maxargs ? "s" : ""); + if (CFG_HELP) toys.exithelp = 0; } // Loop through files listed on the command line @@ -55,6 +55,12 @@ void error_exit(char *msg, ...) { va_list va; + if (CFG_HELP && toys.exithelp) { + *toys.optargs=*toys.argv; + help_main(); + fprintf(stderr,"\n"); + } + va_start(va, msg); verror_msg(msg, 0, va); va_end(va); @@ -75,12 +81,6 @@ void perror_exit(char *msg, ...) exit(toys.exitval); } -// Stub until the online help system goes in. -void usage_exit(void) -{ - exit(1); -} - // Die unless we can allocate memory. void *xmalloc(size_t size) { @@ -45,7 +45,6 @@ void error_msg(char *msg, ...); void perror_msg(char *msg, ...); void error_exit(char *msg, ...); void perror_exit(char *msg, ...); -void usage_exit(void); void *xmalloc(size_t size); void *xzalloc(size_t size); void *xrealloc(void *ptr, size_t size); |