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


Groups > gnu.bash.bug > #15058

Re: Arithmetic evaluation of negative numbers with base prefix

From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: Arithmetic evaluation of negative numbers with base prefix
Date 2019-06-19 10:39 -0400
Message-ID <mailman.454.1560955191.10840.bug-bash@gnu.org> (permalink)
References <20190614141947.GB27242@tower> <dc253e63-de07-6c60-7b20-1688286a43d2@case.edu> <20190617133026.GC27242@tower> <f9efca77-7616-f160-278b-a14062d7491c@case.edu>

Show all headers | View raw


On 6/17/19 9:30 AM, Jeremy Townshend wrote:

> Ilkka Virta's email helpfully pointed me to a somewhat related debate that
> occurred about 11 months ago.  I agree with your comment in this debate:
> 
>   "There would be a good case for rejecting the '10#' because it's missing
>   the value."

I'll probably do that for bash-5.1. The code is in there and tagged for
later.

> 
> It is this silently proceeding with a plausible (but undesirable) output in
> such cases which is especially concerning.

Trying to be helpful rarely works out in every case.

> I cannot find anywhere else in the manual where the word "number", "numeric
> value" or "integer" excludes values less than zero without explicitly stating
> so.  On the other hand phrases like "[if] ...  number/numeric values less than
> zero", "if ...  [not] a number greater than [or equal to] zero" are used
> repeatedly.  In those cases "number" clearly doesn't exclude those less than
> zero.

I'm not sure how relevant that language is to integer constants in
expressions. I could also note that the language describing the base#n
syntax only talks about digits, letters, `@', and `_'.

The bash definition of arithmetic evaluation is taken from C. That includes
integer constants, and, while the base#value syntax clearly extends the C
definition of a constant,  the `-' (and `+', FWIW) is still an operator as
defined by C.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

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


Thread

Re: Arithmetic evaluation of negative numbers with base prefix Chet Ramey <chet.ramey@case.edu> - 2019-06-19 10:39 -0400

csiph-web