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

Re: use script output as regex pattern in folder-fook



On Jul 25 08:15, David Champion wrote:
> >     folder-hook folder1|folder2|folder3 ...
> > 
> > I replaced this with
> > 
> >     folder-hook script.sh| ...
> 
> This approach won't work.  Here's why, and a possible alternative.
> 
> The "script.sh|" notation for incorporating a script's output into your
> muttrc only works where mutt knows that it's looking for a filename or
> a format string.  Otherwise, "script.sh|" is just a literal string.
> In your case, it's a regular expression listing a set of either-or
> patterns, and one of these patterns is an empty string, which matches
> everything since all strings contain an empty string as a subset.
> 
> As Michael said, you can use `script.sh` instead.  This should
> work equally well for most purposes.  The only difference is that
> "script.sh|", when it works, executes the script each time that the
> value is evaluated.  `script.sh` executes the script only once, at
> the time that the muttrc is processed.
> 
> This makes "script.sh|" really useful only when used for "set" variables
> that are evaluated multiple times.  Hooks are evaluated only once
> anyway, so it wouldn't really be meaningful.

Thanks for the clarification. I use "script.sh|" in various "set ..." commands,
so I naively figured I could use it in a folder-hook too.

As I stated in the reply to Michael's message, I'd be happy if something like

    set $my_path=/some/path
    folder-hook `$my_path/script.sh` ...

would be possible. 

> If you really need the same kind of dynamic meaning that "script.sh|"
> provides over `script.sh` 
> [...]

No, not really. I substituted one for the other so I didn't even know there
was some dynamic to use :)

steve