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

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



>     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.

If you really need the same kind of dynamic meaning that "script.sh|"
provides over `script.sh`, you might be able to use a compound
folder-hook -- something like this:

    folder-hook . 'folder-hook \`script.sh\` command...'

or perhaps:

        # all other folder-hooks in folder-hooks.mutt
        folder-hook . 'source folder-hooks.mutt'

These are untested, but its intention is that for each folder change,
mutt will interpret "folder-hook `script.sh` command..." again.  I'm
not sure that the second folder-hook would actually be applied to the
new (now current) folder, though.  It might be necessary to reopen the
folder to make the new folder-hook stick, and that's so unusable as to
make the whole approach worthless.

-- 
 -D.    dgc@xxxxxxxxxxxx    NSIT    University of Chicago