From: Jeff King Date: Tue, 05 May 2020 21:07:41 GMT Subject: Re: [PATCH] CodingGuidelines: drop arithmetic expansion advice to use "$x" Message-ID: <20200505210741.GB645290@coredump.intra.peff.net> In-Reply-To: On Tue, May 05, 2020 at 01:40:03PM -0700, Junio C Hamano wrote: > A new entry in the "What's cooking" report has this: > > * jk/arith-expansion-coding-guidelines (2020-05-04) 1 commit > - CodingGuidelines: drop arithmetic expansion advice to use "$x" > > The coding guideline for shell scripts instructed to refer to a > variable with dollar-sign inside airthmetic expansion to work > around a bug in old versions of bash, which is a thing of the past. > Now we are not forbidden from writing $((var+1)). s/bash/dash/, I think > Writing the last sentence made me wonder if we should go one step > further and actually encourage actively omitting the dollar-sign > from variable reference instead. I don't have a strong preference either way. I gave a few reasons to prefer the dollar-less version in: https://lore.kernel.org/git/20200504151351.GC11373@coredump.intra.peff.net/ but I couldn't find a case where the difference really matters in practice for otherwise-correct code. If we don't care much either way, I'd just as soon not have a rule. We have enough rules as it is, and I don't think either is obvious enough that somebody who is used to one style will get confused by the other. -Peff