Re: Use of if and test in .qmail files

Bruce Guenter <[email protected]> Tue, 30 Oct 2007 11:28:11 -0600
Newsgroups gmane.mail.ezmlm
Message-ID <[email protected]>
On Tue, Oct 30, 2007 at 01:05:32PM -0400, Paul Jarc wrote:
> qmail-local explicitly invokes /bin/sh to run commands in .qmail
> files, so you shouldn't have to worry about csh.

That's what I figured to be most likely, yes.

> test -f would be
> more portable than test -e, though.

Really?  That surprises me, as test -e is the simpler condition.

> I'm not sure about "!".

The trick with using a bare test is that the conditional join must be ||
and not && in order that, if the file being tested does not exist, qmail
will still execute the other commands.  So, for example:

	| test -e DIR/threaded && ezmlm-archive DIR

will cause all deliveries to fail if DIR/threaded does not exist, even
though the above is the most obvious conditional expression.  As such,
the test must be negated.

Using if is safer, as it will throw away the exit code of the condition.
-- 
Bruce Guenter <[email protected]>                http://untroubled.org/
	I do custom software development.  Email me for details.
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFHJ2mr6W+y3GmZgOgRAmiLAJ9R2ujRIm/JDGpeINoROgm/g3eAgACfWsPg
Mpx8tyGkG8oPdPlv/9n9EVQ=
=vE8a
-----END PGP SIGNATURE-----