<<< Date Index >>>     <<< Thread Index >>>

Re: regression: attaching files from command line fails



* Thu Oct 23 2008 Aron Griffis <agriffis@xxxxxxxxx>
> Aron Griffis wrote:  [Thu Oct 23 2008, 10:07:02AM EDT]
> > What OS is this?  There are some patches recently in mutt that
> > affect cmdline processing, but your example works for me.
> 
> My mistake, your example doesn't work for me.  The reason is that
> -a accepts multiple attachments, so you need to specify -- before
> addresses:
> 
>     mutt -a file -- addr </dev/null

This is not documented. The manual says:

| To attach multiple files, separating filenames and recipient
| addresses with "--" is mandatory

I read it as
"you don't need '--' if you are to attach a single file."


> Prior to http://dev.mutt.org/trac/changeset/31c9e9727d42 mutt
> would scan for a double-dash in the arguments, and would treat -a
> differently depending on whether the double-dash was found.  This
> was error-prone and inconsistent on different operating systems.
> See http://dev.mutt.org/trac/ticket/3097
> 
> I hope we don't have to reinstate a hack to pre-detect the
> double-dash... Just digs us deeper into the mess of a polymorphic
> command-line.

What about post-detect, instead of pre-detect?

diff -r 5ea9f336dd60 main.c
--- a/main.c    Mon Oct 20 11:50:38 2008 -0700
+++ b/main.c    Tue Oct 28 13:45:04 2008 +0900
@@ -533,7 +533,7 @@
   char *draftFile = NULL;
   char *newMagic = NULL;
   HEADER *msg = NULL;
-  LIST *attach = NULL;
+  LIST *attach = NULL, *tmp_attach = NULL;
   LIST *commands = NULL;
   LIST *queries = NULL;
   LIST *alias_queries = NULL;
@@ -700,6 +700,19 @@
       default:
        mutt_usage ();
       }
+  }
+  /* Only the first arg will be attached
+   * if -a is not terminated with double_dash.
+   * FIXME: malloc'd strings are not FREEd */
+  if (double_dash == argc && attach)
+  {
+    tmp_attach = attach;
+    while (tmp_attach->next)
+    {
+      argv[nargc++] = tmp_attach->next->data;
+      tmp_attach->next = tmp_attach->next->next;
+    }
+    attach->next = NULL;
   }
 
   /* collapse remaining argv */

-- 
tamo