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

Re: [PATCH] new fmtpipe updates



On Wednesday, 07 March 2007 at 15:00, David Champion wrote:
> I've attached two patches, fmtpipe.2 and fmtpipe.3.  These are
> mutually-exclusive alternatives to current problems.  Fmtpipe.3 takes
> a somewhat new approach to the whole thing, for reasons I'll outline
> below.  Fmtpipe.2 addresses previous concerns as best I can manage,
> given certain constraints.  It includes:
> 
> * better determination of whether to filter the string -- instead
>   of choosing to filter when '|' is encountered at EOL, we discover
>   the pipe up front and operate on a copy of the src buffer with
>   the pipe removed.  M_FORMAT_NOFILTER is ORed into flags to prevent
>   any additional recursions that may occur.
> 
> * A pair of temporary BUFFERs are used so that mutt_extract_token() can
>   find the length of the command name and properly discount it from
>   line width considerations.
> 
> * as a result, %> basically works without incurring more filter
>   instances.
> 
> But even now, a problem with '%> ' is that it expands into a bunch of
> spaces, and passing these into mutt_create_filter() (which uses shell to
> execute the filter command) essentially compresses these back into one
> space.  You can avoid that by shell-quoting the argument, but then the
> extra quotes are counted in line widths, too, and the final result is
> mis-sized if you use %>.

I think I prefer force-quoting or sending the input via stdin.  It
means the receiver has to be a little smarter about parsing, I know,
but there isn't a different quoting scheme for piped vs non-piped
format strings. I suspect you could probably get the shell to do the
work for you by putting quotes around your arguments and then getting
shell to reparse (this may be easier for mutt if it sends the input
via stdin).

I'm also a little nervous about what happens in your second patch if
people are naive about quoting (though I haven't actually tried
it). What happens, for instance, if an unquoted %? has spaces in it:

%?M?  foo  ? bar?

By the way, it would probably also be good to handle \| at the end of
a string.