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

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

From
Jeff King <peff@peff.net>
Date
May 4, 2020, 16:07 UTC
Message-ID
<20200504160709.GB12842@coredump.intra.peff.net>
In-Reply-To
<xmqqh7wviud9.fsf@gitster.c.googlers.com>
On Mon, May 04, 2020 at 08:37:38AM -0700, Junio C Hamano wrote:
Show 9 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > Hmm, somehow I didn't know about that rule. We have many cases already
> > in the test suite and elsewhere (try grepping for '$(([a-z]', which
> > isn't exhaustive but turns up many examples).
> >
> > Maybe it's time to loosen the rule?
> 
> Let's do that.  It's time.
Here it is in patch form for your convenience.
-- >8 --
Subject: CodingGuidelines: drop arithmetic expansion advice to use "$x"

The advice to use "$x" rather than "x" in arithmetric expansion was working around a dash bug fixed in 0.5.4. Even Debian oldstable has 0.5.7 these days. And in the meantime, we've added almost two dozen instances of the "x" form which you can find with:

  git grep '$(([a-z]'

and nobody seems to have complained. Let's declare this workaround obsolete and simplify our style guide.

Helped-by: Danh Doan <congdanhqx@gmail.com>
Signed-off-by: Jeff King <peff@peff.net>
---
 Documentation/CodingGuidelines | 4 ----
 1 file changed, 4 deletions(-)
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 390ceece52..a89e8dcfbc 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -95,10 +95,6 @@ For shell scripts specifically (not exhaustive):
 
  - We use Arithmetic Expansion $(( ... )).
 
- - Inside Arithmetic Expansion, spell shell variables with $ in front
-   of them, as some shells do not grok $((x)) while accepting $(($x))
-   just fine (e.g. dash older than 0.5.4).
-
  - We do not use Process Substitution <(list) or >(list).
 
  - Do not write control structures on a single line with semicolon.
-- 
2.26.2.957.g6dc93e954a
Previous: Junio C HamanoNext: Carlo Marcelo Arenas Belón
Message 7 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.