}
}
+void print_help(FILE *out) {
+
+ fprintf(out, "Selector version %s-R%s (%s)\n", VERSION, REVISION_NUMBER, UNAME);
+ fprintf(out, "Written by Francois Fleuret <francois@fleuret.org>.\n");
+ fprintf(out, "\n");
+ fprintf(out, "Usage: selector [options] [<filename1> [<filename2> ...]]\n");
+ fprintf(out, "\n");
+ fprintf(out, " -h show this help\n");
+ fprintf(out, " -v inject the selected line in the tty\n");
+ fprintf(out, " -w quote control characters with ^Qs when using -v\n");
+ fprintf(out, " -d remove duplicated lines\n");
+ fprintf(out, " -b remove the bash history line prefix\n");
+ fprintf(out, " -z remove the zsh history line prefix\n");
+ fprintf(out, " -i invert the order of lines\n");
+ fprintf(out, " -e start in regexp mode\n");
+ fprintf(out, " -a start in case sensitive mode\n");
+ fprintf(out, " -m monochrome mode\n");
+ fprintf(out, " -q make a flash instead of a beep on an edition error\n");
+ fprintf(out, " -- all following arguments are filenames\n");
+ fprintf(out, " -t <title>\n");
+ fprintf(out, " add a title in the modeline\n");
+ fprintf(out, " -c <fg modeline> <bg modeline> <fg highlight> <bg highlight>\n");
+ fprintf(out, " set the display colors\n");
+ fprintf(out, " -o <output filename>\n");
+ fprintf(out, " set a file to write the selected line to\n");
+ fprintf(out, " -s <pattern separator>\n");
+ fprintf(out, " set the symbol to separate substrings in the pattern\n");
+ fprintf(out, " -x <label separator>\n");
+ fprintf(out, " set the symbol to terminate the label\n");
+ fprintf(out, " -l <max number of lines>\n");
+ fprintf(out, " set the maximum number of lines to take into account\n");
+ fprintf(out, "\n");
+}
+
/*********************************************************************/
/* A quick and dirty hash table */
}
if(show_help || error) {
- FILE *out;
- if(show_help) {
- out = stdout;
+ if(error) {
+ print_help(stderr);
+ exit(EXIT_FAILURE);
} else {
- out = stderr;
- }
-
- fprintf(out, "Selector version %s-R%s (%s)\n", VERSION, REVISION_NUMBER, UNAME);
- fprintf(out, "Written by Francois Fleuret <francois@fleuret.org>.\n");
- fprintf(out, "\n");
- fprintf(out, "Usage: %s [options] [<filename1> [<filename2> ...]]\n",
- argv[0]);
- fprintf(out, "\n");
- fprintf(out, " -h show this help\n");
- fprintf(out, " -v inject the selected line in the tty\n");
- fprintf(out, " -w quote control characters with ^Qs when using -v\n");
- fprintf(out, " -d remove duplicated lines\n");
- fprintf(out, " -b remove the bash history line prefix\n");
- fprintf(out, " -z remove the zsh history line prefix\n");
- fprintf(out, " -i invert the order of lines\n");
- fprintf(out, " -e start in regexp mode\n");
- fprintf(out, " -a start in case sensitive mode\n");
- fprintf(out, " -m monochrome mode\n");
- fprintf(out, " -q make a flash instead of a beep on an edition error\n");
- fprintf(out, " -- all following arguments are filenames\n");
- fprintf(out, " -t <title>\n");
- fprintf(out, " add a title in the modeline\n");
- fprintf(out, " -c <fg modeline> <bg modeline> <fg highlight> <bg highlight>\n");
- fprintf(out, " set the display colors\n");
- fprintf(out, " -o <output filename>\n");
- fprintf(out, " set a file to write the selected line to\n");
- fprintf(out, " -s <pattern separator>\n");
- fprintf(out, " set the symbol to separate substrings in the pattern\n");
- fprintf(out, " -x <label separator>\n");
- fprintf(out, " set the symbol to terminate the label\n");
- fprintf(out, " -l <max number of lines>\n");
- fprintf(out, " set the maximum number of lines to take into account\n");
- fprintf(out, "\n");
- exit(error);
+ print_help(stdout);
+ exit(EXIT_SUCCESS);
+ }
}
lines = safe_malloc(nb_lines_max * sizeof(char *));