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


Groups > gnu.bash.bug > #14327

Re: Number with sign is read as octal despite a leading 10#

From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: Number with sign is read as octal despite a leading 10#
Date 2018-07-10 23:17 -0400
Organization ITS, Case Western Reserve University
Message-ID <mailman.3415.1531279108.1292.bug-bash@gnu.org> (permalink)
References (2 earlier) <71850c03-54d3-6a7e-1d29-136950d9e139@iki.fi> <a0b100e7-3e14-e56e-8ffb-fcaeca587bf1@case.edu> <CA+n9pTwOZNdmWqEYwE5cDohArgvZ285vSt-F=hw=ZGb8weO2qA@mail.gmail.com> <471822f3-4484-59b5-0433-fc394dc9b34a@case.edu> <CA+n9pTzNU4stJykWKAJkPzwwrkmxzirWmuUT_xA9U=ZWsh3nMQ@mail.gmail.com>

Show all headers | View raw


On 7/10/18 4:57 PM, Isaac Marcos wrote:
> Chet Ramey (<chet.ramey@case.edu <mailto:chet.ramey@case.edu>>) wrote:
> 
>     On 7/10/18 2:48 PM, Isaac Marcos wrote:
>     >     That is not an integer constant. Integer constants don't begin
>     with `-'.
> 
> 
> That makes negative numbers invalid.

You need to look at the difference between constants and operators. This is
what allows you to write $(( -a )), for instance.

>     Because of the difference between an operator and a constant. Unary plus
>     and minus have a higher precedence than arithmetic operators. So if you
>     expand the `a' to an expression, which is what happens, the expression
>     consists of an operator (+ or -) and a constant, and that expression has
>     a higher precedence than the +. You might think about why using `$a' in
>     place of the `a' would not work all the time.
> 
> 
> 
> I don't care. All other shells do this correctly. It makes you the only one
> wrong.

"All other shells" is kind of a broad statement.

-- 
``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: Number with sign is read as octal despite a leading 10# Chet Ramey <chet.ramey@case.edu> - 2018-07-10 23:17 -0400

csiph-web