diff options
| author | B. Watson <urchlay@slackware.uk> | 2025-11-22 02:33:29 -0500 |
|---|---|---|
| committer | B. Watson <urchlay@slackware.uk> | 2025-11-22 02:33:29 -0500 |
| commit | ceb07d961981f1e553bb6ab0f6145c2aa84f9f5e (patch) | |
| tree | 4660971724ffd4c5acffe2f87211ab12135cab09 | |
| parent | bf5425f6ae2e3666e232d003c6a8a32b38079383 (diff) | |
| download | unalf-ceb07d961981f1e553bb6ab0f6145c2aa84f9f5e.tar.gz | |
Get rid of dup error messages for invalid getopt() options.
| -rw-r--r-- | TODO.txt | 5 | ||||
| -rw-r--r-- | src/opts.c | 5 |
2 files changed, 4 insertions, 6 deletions
@@ -1,8 +1,3 @@ -- fix dup message for bad opts: - $ ./unalf -X - ./unalf: invalid option -- 'X' - unalf: fatal: invalid option (try -h or --help) - - include some of Alfred's email commentary in the doc dir. - create some alf archives and hexedit them to introduce errors, make @@ -29,6 +29,9 @@ void parse_opts(int argc, char * const *argv) { int opt; char **ig; + /* don't let getopt() print error message for us. */ + opterr = 0; + while((opt = getopt(argc, argv, OPTIONS)) != -1) { switch(opt) { case 'a': opts.txtconv++; break; @@ -45,7 +48,7 @@ void parse_opts(int argc, char * const *argv) { case 'd': opts.outdir = optarg; break; case 'x': add_exclude(optarg); break; default: - fprintf(stderr, "%s: fatal: invalid option (try -h or --help)\n", self); + fprintf(stderr, "%s: fatal: invalid option '-%c' (try -h or --help)\n", self, optopt); exit(1); } } |
