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

Re: Spaces in attached file names



On 2005-03-08, Bill Moseley <moseley@xxxxxxxx> wrote:
> On Tue, Mar 08, 2005 at 06:05:22AM +0100, Thomas Roessler wrote:
> > On 2005-03-07 17:25:22 -0800, Bill Moseley wrote:
> > 
> > > Is this a problem in my mailcap file?  Doesn't seem so as %s is
> > > quoted.  So is mutt not sending the entire path?
> > 
> > Yes, there's a problem with your mailcap file.  Please remove the
> > single ticks around the %s, as mutt adds the necessary quoting
> > itself.
> 
> Ok.  So my first thought was how can that be correct?  First, I don't
> see why an extra set of quote would make a difference.  Indeed, if I
> set my mailcap to
> 
>   application/pdf; /usr/bin/xpdf ''%s''; ...
> 
> then "run-mailcap 'test doc.pdf'" works just fine.

I didn't understand how this could be a problem, either, until I
read that line that worked, then it became clear.  If you put single
quotes around %s and mutt also puts single quotes around %s, the
result is

    ''filename''

That is interpretted by the shell as an empty string concatenated
with the filename concatenated with another empty string,
effectively removing all the quoting.

I verified all this by opening an HTML attachment, then using ps to
see what commands were being run.  (This is on HP-UX.)  With no
quotes around %s in my mailcap,

    text/html; w3m %s; nametemplate=%s.html

ps shows:

    -sh
      mutt
        sh -c w3m '/tmp/mutt.html'
          w3m /tmp/mutt.html

whereas with single quotes around %s,

    text/html; w3m '%s'; nametemplate=%s.html

ps shows:

    -sh
      mutt
        sh -c w3m ''/tmp/mutt.html''
          w3m /tmp/mutt.html

So if you need to quote %s for some reason, putting double quotes
(") around it should work.

> Can someone give me a pointer into the mutt source where this is
> handled?

It's basically the rfc1524_expand_command() function in rfc1524.c
and in the functions it calls.

HTH,
Gary

-- 
Gary Johnson                               | Agilent Technologies
garyjohn@xxxxxxxxxxxxxxx                   | Wireless Division
http://www.spocom.com/users/gjohnson/mutt/ | Spokane, Washington, USA