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

Re: [PATCH 0/3] Fix $((...)) coding style

From
John Keeping <john@keeping.me.uk>
Date
Feb 4, 2016, 13:01 UTC
Message-ID
<20160204130111.GG29880@serenity.lan>
In-Reply-To
<alpine.DEB.2.20.1602041334450.2964@virtualbox>
On Thu, Feb 04, 2016 at 01:38:51PM +0100, Johannes Schindelin wrote:
Show 9 quoted lines
> On Thu, 4 Feb 2016, John Keeping wrote:
> 
> > Using spaces around operators also matches our C coding style.
> 
> Well, by that reasoning you should go the whole nine yards and write
> 
> 	lineno = $(( $lineno + 1 ))
> 
> Except you can't. Because shell code is inherently not like C code.

That isn't my main argument, although I do think the (presumed) rationale for using spaces in C to improve usability applies here as well, even if the confines of the language don't let us go as far as in C.

I'm not actually sure whether spaces inside the enclosing $(( and )) are helpful, we're much less consistent about that than about spaces around binary operators. Having looked at t/ as well now, we really do seem to favour using spaces around the binary operators so I'm further convinced this series is switching the wrong cases.

> What I found particularly interesting about 180bad3 (rebase -i: respect
> core.commentchar, 2013-02-11) was that it *snuck in* that coding style: it
> *changed* the existing one (without rationale in the commit message, too).

The last version of that patch I can find in the archive [1] doesn't add the spaces, so I think they must have been part of Junio's fixup discusses in the following messages. Although I don't think the historic context is useful in deciding which direction to go in the future.

[1] http://article.gmane.org/gmane.comp.version-control.git/216103
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 7 of 13 in “Fix $((...)) coding style”
  1. 0/3 Fix $((...)) coding styleJohannes Schindelin, Feb 4, 2016
  2. 1/3 filter-branch: fix style of $((...) constructJohannes Schindelin, Feb 4, 2016
  3. 2/3 rebase--interactive: adjust the coding style of $((...))Johannes Schindelin, Feb 4, 2016
  4. 3/3 rebase --merge: adjust $((...)) coding styleJohannes Schindelin, Feb 4, 2016
  5. John KeepingFeb 4, 2016
  6. Johannes SchindelinFeb 4, 2016
  7. John KeepingFeb 4, 2016
  8. Johannes SchindelinFeb 4, 2016
  9. John KeepingFeb 4, 2016
  10. Johannes SchindelinFeb 4, 2016
  11. John KeepingFeb 4, 2016
  12. Junio C HamanoFeb 4, 2016
  13. Junio C HamanoFeb 4, 2016

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.