Greetings!
At 2000/12/13/18:58 -0600 David Champion <[EMAIL PROTECTED]> wrote:
> You mean just to test the muttrc file and report parse errors?
>
> How about:
> mutt -F test.muttrc -f /dev/null -e "push x" >/dev/null
That's *way* cool!
Here's a script[1] which uses your idea to test $1 if it's defined and
$HOME/.muttrc if it isn't:
#!/bin/bash
pgm=`basename $0`
die () {
echo 1>&2 "$pgm: $1"
exit 1
} # die
muttrc=$HOME/.muttrc.common
[[ -n $1 ]] && muttrc="$1"
[[ ! -e $muttrc ]] && die "$muttrc: no such file"
[[ ! -f $muttrc ]] && die "$muttrc: not regular file"
[[ ! -r $muttrc ]] && die "$muttrc: cannot open"
echo | mutt -F "$muttrc" -f /dev/null -e "push nnnnnnx" >/dev/null
The "echo |" accounts for the situation where there are so many errors
that mutt prompts the user to hit the enter key:
source: reading aborted due too many errors in /etc/hosts
Press any key to continue...
The n's in front of the x in the push statement are to answer any
interactive mutt questions with "no" before exiting mutt. For
instance, because I don't use ~/Mail, mutt will ask me:
/usr/people/alban/Mail does not exist. Create it? ([y]/n):
and if I only pushed an "x" then then "x" would be used in an attempt to
answer the question. And "x" is not an acceptable answer to mutt. So
when a user ran the above script in this situation, the script would
appear to hang, because mutt was waiting for the answer to the question.
In addition, if the user knew enough to answer "n", the script would
*still* seem to hang. The reason is this. With "push x", the "x" would
have already been used in the first attempt to answer the question. And
because the "x" is no longer pending, it will not be used to exit, and
the mailbox is entered (even if it is /dev/null) and will sit there with
mutt awaiting the next command. Of course, the savvy user could enter
"nx" instead of just "n". The "echo" and the "push nnnnnnx" in the
script should make this unnecessary.
And if there are no interactive questions to be answered, then each
"n" causes mutt to harmlessly try to repeat a search that has never
been specified.
David
P.S. If you run this script and get:
[[: command not found
[[: command not found
[[: command not found
[[: command not found
you need to upgrade to bash 2.x.
[1] I call the script mutttest but undoubtedly there's a better name
than that for it.
--
Live in a world of your own, but always welcome visitors.