Re: [PATCH] CodingGuidelines: drop arithmetic expansion advice to use "$x"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxxxxx/

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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux