Re: [PATCH 2/5] travis-ci: use 'set -e' in the 32 bit Linux build job
- From
Jeff King <peff@peff.net>
- Date
- Jan 24, 2018, 15:49 UTC
- Message-ID
- <20180124154925.GA15803@sigill.intra.peff.net>
- In-Reply-To
- <CAM0VKjkGEfL2j2uzRa9=N5jZFbMMKEHn=UX=thxTAMM_g8TB4g@mail.gmail.com>
On Wed, Jan 24, 2018 at 01:12:48PM +0100, SZEDER Gábor wrote:
Show 9 quoted lines
> >> -test -z $HOST_UID || (CI_USER="ci" && useradd -u $HOST_UID $CI_USER) && > [...] > Indeed, the && chain is broken, I didn't noticed that. > > Luckily it was broken in a way that it didn't lead to false successes: > if installing dependencies fails, then the first && chain > ensures that HOST_UID is not set, and then useradd will error out with > "invalid user ID 'ci'", causing the second && chain to abort the script > and thus breaking the build.
True. :) I didn't even look closely at whether the failures could be correlated.
Show 12 quoted lines
> >> +HOST_UID=$1 > >> +CI_USER=$USER > >> +test -z $HOST_UID || (CI_USER="ci" && useradd -u $HOST_UID $CI_USER) > > > > If this "useradd" step fails, we wouldn't abort the script, because it's > > part of a conditional. You'd need a manual "|| exit 1" at the end of > > this line. Or to use a real "if" block. > > No. It does abort the script, because it isn't part of a conditional. > Try to run the script twice in the same container instance: in the > second run the user already exists, useradd fails and the whole script > aborts.
You're right. I was confusing it with this case:
(one; two) || three
in which we continue with "two" even if "one" fails. But it's only the left-hand side of the || that does that.
-Peff