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

Re: [PATCH 14/15] git-am.sh: replace using expr for arithmetic operations with the equivalent shell builtin

From
Elia Pinto <gitter.spiros@gmail.com>
Date
Feb 4, 2016, 11:53 UTC
Message-ID
<CA+EOSB=ky8E7J0Fa26DjgT=5-X9N09=4kRbGvWZo5K7PhwS7hg@mail.gmail.com>
In-Reply-To
<alpine.DEB.2.20.1602041204430.2964@virtualbox>
2016-02-04 12:14 GMT+01:00 Johannes Schindelin <Johannes.Schindelin@gmx.de>:
Show 26 quoted lines
> Hi Elia,
>
> On Thu, 4 Feb 2016, Elia Pinto wrote:
>
>> -                     this=$(expr "$this" + 1)
>> +                     this=$(( "$this" + 1 ))
>
> Why the funny spaces? We do not do that anywhere in the existing code
> except in three places (2x filter-branch, 1x rebase--interactive, all
> three *not* my fault) and in some tests.
>
> Also, I am *pretty* certain that the quotes break this code:
>
>         me@work MINGW64 /usr/src/git (master)
>         $ this=1
>
>         me@work MINGW64 /usr/src/git (master)
>         $ this=$(( "$this" + 1 ))
>         bash: "1" + 1 : syntax error: operand expected (error token is ""1" + 1 ")
>
> Whereas if you do *not* add the superfluous spaces and quotes, it works:
>
>         me@work MINGW64 /usr/src/git (master)
>         $ this=1
>
>         me@work MINGW64 /usr/src/git (master)
Thanks for noticing.
You are right. I ran the test but did not notice mistakes, my fault.
I will resend. Thanks again.
Best
Show 34 quoted lines
>         $ this=$(($this+1))
>
>         me@work MINGW64 /usr/src/git (master)
>         $ echo $this
>         2
>
> Maybe this is only a problem with Bash 4.3.42 in MSYS2, but I do not think
> so.
>
> *Clicketyclick*
>
> Nope. It also happens in Ubuntu's Bash 4.3.42:
>
>         me@ubuntu-vm  ~/git (master)
>         $ this=1
>
>         me@ubuntu-vm  ~/git (master)
>         $ this=$(( "$this" + 1 ))
>         bash: "1" + 1 : syntax error: operand expected (error token is ""1" + 1 ")
>
>         me@ubuntu-vm  ~/git (master)
>         $ bash --version
>         GNU bash, version 4.3.42(1)-release (x86_64-pc-linux-gnu)
>         Copyright (C) 2013 Free Software Foundation, Inc.
>         License GPLv3+: GNU GPL version 3 or later
>         <http://gnu.org/licenses/gpl.html>
>
>         This is free software; you are free to change and redistribute it.
>         There is NO WARRANTY, to the extent permitted by law.
>
> ... which makes me wonder in which environment you tested this?
>
> Ciao,
> Dscho
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 4 of 9 in “git-am.sh: replace using expr for arithmetic operations with the equivalent shell builtin”
  1. 14/15 git-am.sh: replace using expr for arithmetic operations with the equivalent shell builtinElia Pinto, Feb 4, 2016
  2. 15/15 t4032-diff-inter-hunk-context.sh: replace using expr for arithmetic operations with the equivalent shell builtinElia Pinto, Feb 4, 2016
  3. Johannes SchindelinFeb 4, 2016
  4. Elia PintoFeb 4, 2016
  5. Johannes SchindelinFeb 4, 2016
  6. Junio C HamanoFeb 4, 2016
  7. Eric SunshineFeb 4, 2016
  8. Elia PintoFeb 5, 2016
  9. Stefan BellerFeb 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.