diff options
author | Michael Tüxen <tuexen@fh-muenster.de> | 2011-06-01 09:26:33 +0000 |
---|---|---|
committer | Michael Tüxen <tuexen@fh-muenster.de> | 2011-06-01 09:26:33 +0000 |
commit | 268c5f21b7acefe3192b0b90329051ff216395f7 (patch) | |
tree | eab4706b3fa35cc39e5ab396ad02082b306a28ef /gtk/main.c | |
parent | da6a34fce7dd20a424ba2b3873e1be59d4a2886a (diff) |
Improve handling of command line arg errors (for example "wireshark -f").
From Irene Ruengeler.
svn path=/trunk/; revision=37505
Diffstat (limited to 'gtk/main.c')
-rw-r--r-- | gtk/main.c | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/gtk/main.c b/gtk/main.c index 717bb13a03..4aeb71c007 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -2606,41 +2606,42 @@ main(int argc, char *argv[]) break; } } - argc -= optind; - argv += optind; - if (argc >= 1) { - if (cf_name != NULL) { + if (!arg_error) { + argc -= optind; + argv += optind; + if (argc >= 1) { + if (cf_name != NULL) { + /* + * Input file name specified with "-r" *and* specified as a regular + * command-line argument. + */ + cmdarg_err("File name specified both with -r and regular argument"); + arg_error = TRUE; + } else { + /* + * Input file name not specified with "-r", and a command-line argument + * was specified; treat it as the input file name. + * + * Yes, this is different from tshark, where non-flag command-line + * arguments are a filter, but this works better on GUI desktops + * where a command can be specified to be run to open a particular + * file - yes, you could have "-r" as the last part of the command, + * but that's a bit ugly. + */ + cf_name = g_strdup(argv[0]); + } + argc--; + argv++; + } + + if (argc != 0) { /* - * Input file name specified with "-r" *and* specified as a regular - * command-line argument. + * Extra command line arguments were specified; complain. */ - cmdarg_err("File name specified both with -r and regular argument"); + cmdarg_err("Invalid argument: %s", argv[0]); arg_error = TRUE; - } else { - /* - * Input file name not specified with "-r", and a command-line argument - * was specified; treat it as the input file name. - * - * Yes, this is different from tshark, where non-flag command-line - * arguments are a filter, but this works better on GUI desktops - * where a command can be specified to be run to open a particular - * file - yes, you could have "-r" as the last part of the command, - * but that's a bit ugly. - */ - cf_name = g_strdup(argv[0]); } - argc--; - argv++; - } - - if (argc != 0) { - /* - * Extra command line arguments were specified; complain. - */ - cmdarg_err("Invalid argument: %s", argv[0]); - arg_error = TRUE; } - if (arg_error) { #ifndef HAVE_LIBPCAP if (capture_option_specified) { |