Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Nov 2018 13:04:42 +0100
From:      Mathieu Arnold <mat@FreeBSD.org>
To:        Mathieu Arnold <mat@FreeBSD.org>, ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   Re: svn commit: r483437 - in head/mail/dovecot: . files
Message-ID:  <20181103120442.moqlg4sjv4iezd7x@atuin.in.mat.cc>
In-Reply-To: <20181102214147.3j4jf4bdujgaijjp@ler-imac.local>
References:  <201810292328.w9TNSRHm018030@repo.freebsd.org> <20181031150252.p4lhmlaposwurdgr@ogg.in.absolight.net> <20181102214147.3j4jf4bdujgaijjp@ler-imac.local>

next in thread | previous in thread | raw e-mail | index | archive | help

--3aklw3o4rhsskaxn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Nov 02, 2018 at 04:41:47PM -0500, Larry Rosenman wrote:
> On Wed, Oct 31, 2018 at 04:02:52PM +0100, Mathieu Arnold wrote:
> > On Mon, Oct 29, 2018 at 11:28:27PM +0000, Larry Rosenman wrote:
> > > Modified: head/mail/dovecot/files/dovecot.in
> > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
> > > --- head/mail/dovecot/files/dovecot.in	Mon Oct 29 23:25:58 2018	(r483=
436)
> > > +++ head/mail/dovecot/files/dovecot.in	Mon Oct 29 23:28:26 2018	(r483=
437)
> > > @@ -60,6 +60,14 @@ for config in ${dovecot_config}; do
> > >  	required_files=3D"${config}"
> > >  	command_args=3D"-c ${config}"
> > >  	if [ -s ${config} ]; then
> > > +               ${command} ${command_args} -a 2>/dev/null
> > > +                if [ $? -ne 0 ]; then
> >=20
> > Never test for $?.  This should be:

I should have said "never test for $? (not) being 0".

> >=20
> > if ${command} ${command_args} -a 2>/dev/null; then
> >=20
> > All the rationale in https://github.com/koalaman/shellcheck/wiki/SC2181.
> But, for my own interest, what if I want to put out what the return code
> is in a message?

Shell is pretty limited in term of error control.  You can write:

if foo; then
  # Before anything else, save $?
  error=3D$?
  # do stuff and use $error when needed.
fi

Note that $? can get cloberred by many other things that the command you
run, it can be a redirection error, a shell syntax error in the command in =
the
if, almost too many things to count.

--=20
Mathieu Arnold

--3aklw3o4rhsskaxn
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQKTBAABCgB9FiEEOraXidLtEhBkQLpbOkUW81GDzkgFAlvdjtpfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNB
QjY5Nzg5RDJFRDEyMTA2NDQwQkE1QjNBNDUxNkYzNTE4M0NFNDgACgkQOkUW81GD
zkiMIBAApI9aCn6IutA7FCKut4o4uxCpH5Jv2YXTqAh06T+9z3efBGyWSkV0NBP/
qHr5OE3g30uB7TJdqHUg2vgUIkXiJ1tM4AgyJaV01F4WdWTA/xnaCSz9fO06Dnok
KQbOsqQKFLw24wlpXocKhJ84nBbyfnxlXa0eJuX01zH+NgkQY/4YOpfKKP2AmcUs
6jaImVAOlDnfgZMhCxXt2zSCz5nKFB/LWLI8K50KjDXLNdoNvt0bh3FrImXMN3mL
gjxHfwdwrY15AC7wS0cDPj4QI5HFOaoryNk/x0PQY+sq1XnQVaTP0GwhRHoh1hlH
ga74pQLWQtMlr5/yWwqP/587zFpmSOvBAcDAwgy0rOWLkkon9YYyIxDKXRbULaFj
c9dVbRxIESNb92tN+sZlJUomI/Dh3X/CbOWsq9OFT4UjZqMh7fgWhoKku+RqvBmx
UfSiREPJvzN0DOynSno21JJOEqHaTXwXvNixeM7NMw8VemsfOcxKY9E5wLY1rBxc
9+9ZB0PKy+06Jm9/EskqOSd4hx6YlM3Hyy1FX59SMqkTI7fz9JpFEaQVrSaz1CEn
lwSc+eA4IyEsyTNoX2GNIOdhw7ZYkNkg2ESjxhBJ+rM5n95hB3NLMcdo98AxJ6BP
jUp7Aps+anggKI0SMPokEH+a5Sxia50Zvikhro9IY8HNR7R2r+A=
=Pj2/
-----END PGP SIGNATURE-----

--3aklw3o4rhsskaxn--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20181103120442.moqlg4sjv4iezd7x>