On Wed, Dec 13, 2000 at 06:12:43PM -0800, David Alban wrote:
> 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:
(the script itself quoted for context)
> #!/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
>
[snip]
>
> 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.
Just a side note - is there a reason you could not use the standard '['
test operator? Along with some quoting of possibly-null arguments, of
course.. something like:
[ -n "$1" ] && muttrc="$1"
[ ! -e "$muttrc" ] && die "$muttrc: no such file"
[ ! -f "$muttrc" ] && die "$muttrc: not regular file"
[ ! -r "$muttrc" ] && die "$muttrc: cannot open"
Just this way, it works for me in FreeBSD's /bin/sh, which is pretty much
as standard a Bourne shell as you can get..
G'luck,
Peter
--
This inert sentence is my body, but my soul is alive, dancing in the sparks of your
brain.