Piping to a script and receiving commands/variables back

Cameron Simpson cs at cskk.id.au
Tue Mar 13 00:02:45 UTC 2018

On 12Mar2018 23:32, David Woodfall <dave at dawoodfall.net> wrote:
>I've made a shell script that I pipe via a key bind. It parses for
>email address and writes a new procmail rule based on that and the
>name of a folder that I enter on the CLI.
>It works OK, but I'd like to send the name of the folder back to mutt
>and have it save the message there afterwards.
>I've kind of got it working by echoing commands to a tmp file and then
>have mutt source it:
>echo "push <save-message>=$folder<return><sync-mailbox>" \
> > /tmp/newfolder
>I'd much rather know if there's a better way of doing it.

The other alternative is to source its output directly. So the raw command is:


But you want the script to parse a mail message and emit mutt commands for 
sourcing. Possibly you need to (a) save the message to a file (b) run:

  `your-shell-script <the-file`

I'm not sure that is morally any better than your current approach (pipe to 
script, source a file).

My own macro like yours goes:

  folder-hook . 'macro index,pager A "<save-message>+spool-refile<enter><pipe-message>cs-aliases-add-email -quick known<enter>"'

which loads the author into a "known authors" list, which is sort of 
whitelisted by my filtering.

Maybe the simplest approach is for your script to write the new procmail rule 
and _also_ append something to a growing muttrc file. Which you then source at 
the end of the macro?

Cameron Simpson <cs at cskk.id.au> (formerly cs at zip.com.au)

More information about the Mutt-users mailing list