help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is it really necessary to allow operators and whole right hand sides


From: Chet Ramey
Subject: Re: Is it really necessary to allow operators and whole right hand sides to be substituted in (())?
Date: Mon, 17 May 2021 19:18:05 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.1

On 5/17/21 5:07 PM, Peng Yu wrote:
Hi,

$ plus=+; ((x = 1 $plus 2)); declare -p x
declare -x x="3"

I see that the above code works. I think that allowing operators to be
substituted is counterintuitive.

I'm sure you do.

The (( expression )) command is defined to behave this way because that's
how it was implemented in ksh88. It was defined there as equivalent to
`let "expression"' (which had been in ksh from the first version, ksh83)
and `expression' is therefore expanded as if it were within double quotes.

This is consistent with the subsequent definition of $(( expression )),
where all the tokens in expression are expanded the same way: with
parameter expansion, command substitution, and quote removal.

The expression parser gets the results of the expanded expression, just
like any other command, and parses it accordingly.


So it would be better not to allow it when this syntax first appeared?

Why do you continue to relitigate 30-year-old decisions? If you don't want
to put it in your rewrite, leave it out.

Is there an irrefutable reason that this syntax must have been like
this when it was first introduced? Thanks.

Come on.

--
``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/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]