To report a bug, please visit http://bugs.mutt.org/.\n");
static const char *Notice = N_("\
-Copyright (C) 1996-2008 Michael R. Elkins and others.\n\
+Copyright (C) 1996-2009 Michael R. Elkins and others.\n\
Mutt comes with ABSOLUTELY NO WARRANTY; for details type `mutt -vv'.\n\
Mutt is free software, and you are welcome to redistribute it\n\
under certain conditions; type `mutt -vv' for details.\n");
static const char *Copyright = N_("\
Copyright (C) 1996-2007 Michael R. Elkins <me@mutt.org>\n\
Copyright (C) 1996-2002 Brandon Long <blong@fiction.net>\n\
-Copyright (C) 1997-2007 Thomas Roessler <roessler@does-not-exist.org>\n\
+Copyright (C) 1997-2008 Thomas Roessler <roessler@does-not-exist.org>\n\
Copyright (C) 1998-2005 Werner Koch <wk@isil.d.shuttle.de>\n\
-Copyright (C) 1999-2008 Brendan Cully <brendan@kublai.com>\n\
+Copyright (C) 1999-2009 Brendan Cully <brendan@kublai.com>\n\
Copyright (C) 1999-2002 Tommi Komulainen <Tommi.Komulainen@iki.fi>\n\
Copyright (C) 2000-2002 Edmund Grimley Evans <edmundo@rano.org>\n\
+Copyright (C) 2006-2009 Rocco Rutte <pdmef@gmx.net>\n\
\n\
Many others not mentioned here contributed code, fixes,\n\
and suggestions.\n");
puts _(
"usage: mutt [<options>] [-z] [-f <file> | -yZ]\n\
mutt [<options>] [-x] [-Hi <file>] [-s <subj>] [-bc <addr>] [-a <file> [...]] [--] <addr> [...]\n\
+ mutt [<options>] [-x] [-s <subj>] [-bc <addr>] [-a <file> [...]] [--] <addr> [...] < message\n\
mutt [<options>] -p\n\
mutt [<options>] -A <alias> [...]\n\
mutt [<options>] -Q <query> [...]\n\
"-DL_STANDALONE "
#endif
- "\n"
-
#ifdef USE_FCNTL
"+USE_FCNTL "
#else
#else
"-USE_FLOCK "
#endif
- );
+ );
puts (
#ifdef USE_POP
"+USE_POP "
#else
"-USE_SMTP "
#endif
-
-#ifdef USE_GSS
- "+USE_GSS "
-#else
- "-USE_GSS "
-#endif
-
+ "\n"
#ifdef USE_SSL_OPENSSL
"+USE_SSL_OPENSSL "
#else
"-USE_SASL "
#endif
+#ifdef USE_GSS
+ "+USE_GSS "
+#else
+ "-USE_GSS "
+#endif
#if HAVE_GETADDRINFO
"+HAVE_GETADDRINFO "
int dump_variables = 0;
extern char *optarg;
extern int optind;
- int attach_sep = 0;
+ int double_dash = argc, nargc = 1;
/* sanity check against stupid administrators */
memset (Options, 0, sizeof (Options));
memset (QuadOptions, 0, sizeof (QuadOptions));
- for (i = 1; i < argc; i++)
- if (!strcmp(argv[i], "--"))
+ for (optind = 1; optind < double_dash; )
+ {
+ /* We're getopt'ing POSIXLY, so we'll be here every time getopt()
+ * encounters a non-option. That could be a file to attach
+ * (all non-options between -a and --) or it could be an address
+ * (which gets collapsed to the front of argv).
+ */
+ for (; optind < argc; optind++)
{
- attach_sep = i;
- break;
+ if (argv[optind][0] == '-' && argv[optind][1] != '\0')
+ {
+ if (argv[optind][1] == '-' && argv[optind][2] == '\0')
+ double_dash = optind; /* quit outer loop after getopt */
+ break; /* drop through to getopt */
+ }
+
+ /* non-option, either an attachment or address */
+ if (attach)
+ attach = mutt_add_list (attach, argv[optind]);
+ else
+ argv[nargc++] = argv[optind];
}
- while ((i = getopt (argc, argv, "A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
- switch (i)
- {
+ if ((i = getopt (argc, argv, "+A:a:b:F:f:c:Dd:e:H:s:i:hm:npQ:RvxyzZ")) != EOF)
+ switch (i)
+ {
case 'A':
alias_queries = mutt_add_list (alias_queries, optarg);
break;
case 'd':
#ifdef DEBUG
- debuglevel = atoi (optarg);
+ if (mutt_atoi (optarg, &debuglevel) < 0 || debuglevel <= 0)
+ {
+ fprintf (stderr, _("Error: value '%s' is invalid for -d.\n"), optarg);
+ return 1;
+ }
printf (_("Debugging at level %d.\n"), debuglevel);
#else
printf _("DEBUG was not defined during compilation. Ignored.\n");
default:
mutt_usage ();
- }
+ }
+ }
+
+ /* collapse remaining argv */
+ while (optind < argc)
+ argv[nargc++] = argv[optind++];
+ optind = 1;
+ argc = nargc;
switch (version)
{
/* Initialize crypto backends. */
crypt_init ();
+ if (newMagic)
+ mx_set_magic (newMagic);
+
if (queries)
{
for (; optind < argc; optind++)
return rv;
}
- /* if an -a option is present, all non-option arguments before -- are considered attachments */
- if (attach)
- for (; optind <= attach_sep; optind++)
- attach = mutt_add_list (attach, argv[optind]);
-
- if (newMagic)
- mx_set_magic (newMagic);
-
if (!option (OPTNOCURSES))
{
SETCOLOR (MT_COLOR_NORMAL);
if (!option (OPTNOCURSES))
mutt_endwin (NULL);
perror (tempfile);
- fclose (fin);
+ safe_fclose (&fin);
FREE (&tempfile);
exit (1);
}
mutt_copy_stream (fin, fout);
else if (bodytext)
fputs (bodytext, fout);
- fclose (fout);
+ safe_fclose (&fout);
if (fin && fin != stdin)
- fclose (fin);
+ safe_fclose (&fin);
}
}