Re: Parametrize shell escape command

"Kevin J. McCarthy" <[email protected]>
Newsgroups gmane.mail.mutt.user
Message-ID <Z3NOvuRcLXPcXUOe@qinghai>
On Mon, Dec 30, 2024 at 11:38:45AM -0800, [email protected] wrote:
>for my next mutt tweak, my goal is to set up a macro key binding which 
>will go in the pager keymap and, as its main job, will execute a 
><shell-escape>. The part which -- as far as I can see -- is nontrivial: 
>I need to pass the name of the current folder as an argument to the 
>executed script.
>
>It is easy enough to set up a series of folder-hook mutt config 
>commands so that the name ends up in a user mutt variable, say 
>$my_folder_name. The seeming difficulty is in exporting this value to 
>the external environment (in the precise Unix sense of this term). So 
>far, any way I've thought of doing this turned out to only "beg the 
>question".

The safest way might be to just use an environment variable instead. 
Then, you can deal with parameter quoting issues properly in your 
script, in a way that Mutt can't.

However, if it has to be a parameter, and you're not concerned about 
parameter quoting, you could try redefining the macro in a folder hook 
too, after the mutt user variable is regenerated:

folder-hook . 'set my_folder=$folder;set folder="XXX";set visual=^'
folder-hook . 'set my_mailbox=$visual;setenv MYMAILBOX $visual'
folder-hook . 'set folder=$my_folder'
folder-hook . 'macro index ,q "<shell-escape>echo $my_mailbox > /tmp/foo<enter>"'

-- 
Kevin J. McCarthy
GPG Fingerprint: 8975 A9B3 3AA3 7910 385C  5308 ADEF 7684 8031 6BDA
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEiXWpszqjeRA4XFMIre92hIAxa9oFAmdzTr4ACgkQre92hIAx
a9ol7g/+PFkRT9iug5DD9QyczMGsFDqfjT3Dnkc0zWbmYDdtsDrYw5I1tJqKITXE
KhH1R703OY70SMtkbm2ay3+05vyXfwJnNL85hFs1JQWzBWopbaTQNMYAxapDJwam
QfpoJ3LoUPHvgm3qdkRCkMFQF82IgA04debZVOTAp+1BUbdjGgcLolNGu0AGnG8v
loVVTVNJDpFyjo9dWdbbxYsd/+7uuSr11BXN42mY1Xu54wxA8dyC/oGLM9YOZNM1
5H/E3ex/VpS2UFNP3jyhbQ3zQwo1UDDB3DSJX9UI8rDXXSFckGDYHIgTndZOo7gc
PKgYrqfOfUXE+C0kkIzdes2HESiGWZGdfqxW+aOK+SKIjGQ1OE3sFwdq1slvq4jb
hmojhzRZJ4XlXlHVnsFjDgxp/bnhNoD6BL5IRHYbGLpZMzWCYe1ECQOL6dvr8fHv
VDsMTy652tPDiC1X8IPRn4r9H1cwciQFzSYzBIUAiaIuVF2xc5PI67cm8CBJgrdm
mk9MTNWuRSmhY5+V3YW0JxK7HvHQiWYVxqqnGgRYZdHCop5jztgw1JJEHNGbOgrg
qyd9gkydYjnyqLQcSiq5Ok1yQ9VJT/+bu+93eauAxhmNAc822fc9f9NGToxNDY++
jGH4QeNfRGg+0g4qtuo20y7VVqbobdZWWRIhG6oG+QgquxcfUuE=
=dAA1
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.