git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jeff King <peff@peff.net>
Date
May 5, 2020, 21:07 UTC
Message-ID
<20200505210741.GB645290@coredump.intra.peff.net>
In-Reply-To
<xmqqr1vy9kv0.fsf@gitster.c.googlers.com>
On Tue, May 05, 2020 at 01:40:03PM -0700, Junio C Hamano wrote:
Show 9 quoted lines
> 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
Previous: Junio C HamanoNext: Junio C Hamano
Message 13 of 21 in “git for-each-ref - sorting by multiple keys”
  1. climeMay 2, 2020
  2. Jeff KingMay 3, 2020
  3. 1/2 ref-filter: apply --ignore-case to all sorting keysJeff King, May 3, 2020
  4. Danh DoanMay 3, 2020
  5. Jeff KingMay 4, 2020
  6. Junio C HamanoMay 4, 2020
  7. CodingGuidelines: drop arithmetic expansion advice to use "$x"Jeff King, May 4, 2020
  8. Carlo Marcelo Arenas BelónMay 4, 2020
  9. Jeff KingMay 4, 2020
  10. Junio C HamanoMay 4, 2020
  11. Danh DoanMay 4, 2020
  12. Junio C HamanoMay 5, 2020
  13. Jeff KingMay 5, 2020
  14. Junio C HamanoMay 5, 2020
  15. Junio C HamanoMay 4, 2020
  16. Jeff KingMay 5, 2020
  17. Taylor BlauMay 5, 2020
  18. 2/2 ref-filter: apply fallback refname sort only after all user sortsJeff King, May 3, 2020
  19. Junio C HamanoMay 4, 2020
  20. Taylor BlauMay 5, 2020
  21. climeMay 3, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.