From de01c51ecb3918f427aa76281351749c8ad07ed6 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 27 Mar 2012 12:35:13 +0200 Subject: Print warning for arguments not considered an option. GnuPG requires that options are given before other arguments. This can sometimes be confusing. We now print a warning if we found an argument looking alike a long option without being preceded by the stop option. This is bug#1343. * common/argparse.h (ARGPARSE_FLAG_STOP_SEEN): New. * common/argparse.c (arg_parse): Set new flag. * g10/gpg.c (main): Print the warning. * agent/gpg-agent.c (main): Ditto. * dirmngr/dirmngr.c (main): Ditto. * g13/g13.c (main): Ditto. * scd/scdaemon.c (main): Ditto. * sm/gpgsm.c (main): Ditto. * tools/gpg-connect-agent.c (main): Ditto. * tools/gpgconf.c (main): Ditto. --- tools/gpg-connect-agent.c | 12 ++++++++++++ tools/gpgconf.c | 10 ++++++++++ tools/gpgtar.c | 10 ++++++++++ 3 files changed, 32 insertions(+) (limited to 'tools') diff --git a/tools/gpg-connect-agent.c b/tools/gpg-connect-agent.c index d340c7f0e..0ef52fc14 100644 --- a/tools/gpg-connect-agent.c +++ b/tools/gpg-connect-agent.c @@ -1226,6 +1226,18 @@ main (int argc, char **argv) if (log_get_errorcount (0)) exit (2); + + /* Print a warning if an argument looks like an option. */ + if (!opt.quiet && !(pargs.flags & ARGPARSE_FLAG_STOP_SEEN)) + { + int i; + + for (i=0; i < argc; i++) + if (argv[i][0] == '-' && argv[i][1] == '-') + log_info (_("NOTE: `%s' is not considered an option\n"), argv[i]); + } + + use_tty = (gnupg_isatty (fileno (stdin)) && gnupg_isatty (fileno (stdout))); if (opt.exec) diff --git a/tools/gpgconf.c b/tools/gpgconf.c index cff6e4b3c..a2bba180c 100644 --- a/tools/gpgconf.c +++ b/tools/gpgconf.c @@ -195,6 +195,16 @@ main (int argc, char **argv) if (log_get_errorcount (0)) exit (2); + /* Print a warning if an argument looks like an option. */ + if (!opt.quiet && !(pargs.flags & ARGPARSE_FLAG_STOP_SEEN)) + { + int i; + + for (i=0; i < argc; i++) + if (argv[i][0] == '-' && argv[i][1] == '-') + log_info (_("NOTE: `%s' is not considered an option\n"), argv[i]); + } + fname = argc ? *argv : NULL; switch (cmd) diff --git a/tools/gpgtar.c b/tools/gpgtar.c index b6dd5e10a..d71fe035a 100644 --- a/tools/gpgtar.c +++ b/tools/gpgtar.c @@ -227,6 +227,16 @@ main (int argc, char **argv) if (log_get_errorcount (0)) exit (2); + /* Print a warning if an argument looks like an option. */ + if (!opt.quiet && !(pargs.flags & ARGPARSE_FLAG_STOP_SEEN)) + { + int i; + + for (i=0; i < argc; i++) + if (argv[i][0] == '-' && argv[i][1] == '-') + log_info (_("NOTE: `%s' is not considered an option\n"), argv[i]); + } + switch (cmd) { case aList: -- cgit v1.2.3