Re: [PATCH 29/29] t/test-lib: teach --chain-lint to detect broken &&-chains in subshells
- From
Elijah Newren <newren@gmail.com>
- Date
- Jun 26, 2018, 21:33 UTC
- Message-ID
- <CABPp-BGP2OFYgP5Xm0PMj_NPH2f_UmtMpoHYzcgo544V0e-_Zg@mail.gmail.com>
- In-Reply-To
- <20180626202244.GB2341@sigill.intra.peff.net>
On Tue, Jun 26, 2018 at 1:22 PM, Jeff King <peff@peff.net> wrote:
Show 19 quoted lines
> On Tue, Jun 26, 2018 at 04:17:08PM -0400, Jeff King wrote: > >> I'm not sure if there's a good solution, though. Even if you retained >> the subshells and instead did a chain-lint inside each subshell, like >> this: > > So obviously that means "I don't think there's a good solution with this > approach". > > That whole final patch simultaneously impresses and nauseates me. Your > commit message says "no attempt is made at properly parsing shell code", > but we come pretty darn close. I almost wonder if we'd be better off > just parsing some heuristic subset and making sure (via review or > linting) that our tests conform. > > Another option is to not enable this slightly-more-dangerous linting by > default. But that would probably rob it of its usefulness, since it > would just fall to some brave soul to later crank up the linting and fix > everybody else's mistakes.
This may be a dumb question, but why can't we run under errexit? If we could do that, we wouldn't need the &&-chaining, and bash would parse the shell for us and exit whenever one command failed. (Is the reason for this documented somewhere? I couldn't find it...)