Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15239

Re: expression evaluation problem

Path csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Greg Wooledge <wooledg@eeg.ccf.org>
Newsgroups gnu.bash.bug
Subject Re: expression evaluation problem
Date Wed, 24 Jul 2019 14:49:43 -0400
Lines 28
Approved bug-bash@gnu.org
Message-ID <mailman.2168.1563994202.2688.bug-bash@gnu.org> (permalink)
References <5D3889D2.3090101@tlinx.org> <20190724175103.GN1218@eeg.ccf.org> <5D38A6BF.9020309@tlinx.org> <20190724184943.GO1218@eeg.ccf.org>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace usenet.stanford.edu 1563994203 8657 209.51.188.17 (24 Jul 2019 18:50:03 GMT)
X-Complaints-To action@cs.stanford.edu
Cc bug-bash <bug-bash@gnu.org>
To L A Walsh <bash@tlinx.org>
Envelope-to bug-bash@gnu.org
Mail-Followup-To L A Walsh <bash@tlinx.org>, bug-bash <bug-bash@gnu.org>
Content-Disposition inline
In-Reply-To <5D38A6BF.9020309@tlinx.org>
User-Agent Mutt/1.10.1 (2018-07-13)
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From 139.137.100.1
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <20190724184943.GO1218@eeg.ccf.org>
X-Mailman-Original-References <5D3889D2.3090101@tlinx.org> <20190724175103.GN1218@eeg.ccf.org> <5D38A6BF.9020309@tlinx.org>
Xref csiph.com gnu.bash.bug:15239

Show key headers only | View raw


On Wed, Jul 24, 2019 at 11:43:11AM -0700, L A Walsh wrote:
> Those aren't my variables.
> If you assign the integer attribute to a variable it isn't the same
> as when you don't.

In this case it *is*, because everything is being fed to an arithmetic
command anyway.

Simplifying the bug report as much as possible lets us avoid
confusing and unnecessary diversions.

> > The ${str:2*c:2} part is performed first, while c is still 0, and it
> > expands to "cf".
> >   
> ---
>     Why?  It isn't even necessary when 'c' is greater than 'uxtra'

Because that's how bash works.

              $((expression))

       The expression is treated as if it were within  double  quotes,  but  a
       double  quote inside the parentheses is not treated specially.  All to‐
       kens in the expression undergo parameter and variable  expansion,  com‐
       mand  substitution,  and  quote  removal.  The result is treated as the
       arithmetic expression to be evaluated.  Arithmetic  expansions  may  be
       nested.

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: expression evaluation problem Greg Wooledge <wooledg@eeg.ccf.org> - 2019-07-24 14:49 -0400

csiph-web