On 13Nov2015 08:00, Sandro Santilli <s...@keybit.net> wrote:
On Fri, Nov 13, 2015 at 09:05:30AM +1100, Cameron Simpson wrote:
On 12Nov2015 10:24, Sandro Santilli <s...@keybit.net> wrote:
>Is there a way to start mutt in "reply" mode, starting
>from a mbox-formatted mail in input ?
Have you tried something like:
mutt -f mbox-file -e 'push "<reply><quit>"'
Thanks, works great ! I think I'll wrap this up in a script for
mail-based peer review of code under git, something like this:
TMPMBOX=$$.git.mbox
git format-patch --stdout HEAD^^..HEAD^ > ${TMPMBOX}
mutt -f /tmp/x -e 'push "<reply><quit>"'
rm ${TMPMBOX}
Do you think there's any way to avoid the temporary file ?
Not really. You will need something to work with.
You could alternatively construct a new template message from scratch and then
invoke mutt using it with mutt's -H option:
cat >"$tmpf" <<X
Subject: about your patch
X
git format-patch --stdout 'HEAD^^..HEAD^' >>"$tmpf"
mutt -H "$tmpf" the-patch-author
BTW, as a matter of shell coding practice, two things:
Firstly, try to be reliable in cleanup. I tend to do temp files like this:
... script top ...
: ${TMPDIR:=/tmp}
tmpf=$TMPDIR/git$$.mbox
trap 'rm -f -- "$tmpf"' 0 1 2 13 15
... work using "$tmpf" ...
This removes the temp file on normal and interrupted exit. Tidier.
Secondly, avoid $CAPITALS as variable names unless they are to be exported.
Using all caps names runs a much higher risk of conflicting with an exported
variable. An important part of shell programming is knowing that if you receive
a variable from the environment (as you receive $PATH and $HOME) then that
variable is _automatically_ exported. So if you muck with it in a script, your
actions are exported. Since you cannot expect to ave personal knowledge of all
the variables that might be in play in the environment, you should avoid it
entirely when using script-local variables like your temp file. And the
convention for that is that lowercase variables are not exported. Therefore, if
everyone uses lowercase names for script local variables, accidents are avoided
without requiring omniscience in programmers.
You will see uppercase names used in heaps of script examples. They are _bad_
examples, in this regard.
Cheers,
Cameron Simpson <c...@zip.com.au>