[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a
From: |
alex xmb ratchev |
Subject: |
Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- ") |
Date: |
Thu, 23 Mar 2023 13:15:19 +0100 |
On Thu, Mar 23, 2023, 13:08 alex xmb ratchev <fxmbsw7@gmail.com> wrote:
>
>
> On Thu, Mar 23, 2023, 13:03 Kerin Millar <kfm@plushkava.net> wrote:
>
>> On Thu, 23 Mar 2023 12:38:58 +0100
>> alex xmb ratchev <fxmbsw7@gmail.com> wrote:
>>
>> > On Thu, Mar 23, 2023, 12:21 Kerin Millar <kfm@plushkava.net> wrote:
>> >
>> > > On Thu, 23 Mar 2023 11:32:33 +0100
>> > > alex xmb ratchev <fxmbsw7@gmail.com> wrote:
>> > >
>> > > > i remember doing && (( code
>> > > > maybe i didnt '=' in action there
>> > > >
>> > > > (( a = 8 , a > 4 && a -= 2 || a-- ))
>> > > >
>> > > > bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to
>> > > > non-variable (error token is "-= 2 || a-- ")
>> > > >
>> > > >
>> > > > (( a = 8 , a > 4 && a-- && a-- || a-- ))
>> > > >
>> > > > works
>> > > > a=6
>> > > >
>> > > > ..
>> > > > i suppose this is a (( lex bug where u didnt include || && in op
>> for =
>> > >
>> > > I agree that it looks like a possible bug in the parser. It works if
>> > > parentheses are used to disambiguate one of the subtractions.
>> > >
>> > > $ (( a = 8 , a > 4 && (a -= 2) || a-- )); declare -p a
>> > > declare -- a="6"
>> > >
>> > > Even when made to work, I would consider it to be poor. Consider what
>> > > happens below. It is a fine example of what can happen in the course
>> of
>> > > writing unconventional code without understanding the consequences.
>> > >
>> >
>> > i extra >4 to prevent minus
>>
>> Yes, but ...
>>
>> >
>> > $ (( a = 2 , a > 1 && (a -= 2) || a-- )); declare -p a
>> > > declare -- a="-1"
>>
>> The point was that the intent of the code doesn't match the outcome. The
>> code suggests that 2 should be deducted from 2. Instead of 0, we end up
>> with -1. So, && || is a fairly effective way of writing bugs (just as it
>> can be outside the arithmetic context, sometimes).
>>
>
> yes , no more && ||
> but , your wrong data example ( light misunderstanding )
> the : ( a =1 ) at the end of the new code
>
this is simply cpu count minus a bit for loadbalance
i have no -1 -2 .. i think
> its a logical error here , u think i other data ( with wrong result -1 )
> but i dont ..
>
> ehm.. sorry
>
> --
>> Kerin Millar
>>
>
- Fwd: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- "), (continued)
- Message not available
- Message not available
- Fwd: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- "), alex xmb ratchev, 2023/03/23
- Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- "), alex xmb ratchev, 2023/03/23
Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- "), Kerin Millar, 2023/03/23
- Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- "), alex xmb ratchev, 2023/03/23
- Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- "), alex xmb ratchev, 2023/03/23
- Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- "), alex xmb ratchev, 2023/03/23
- Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- "), Greg Wooledge, 2023/03/23
- Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- "), alex xmb ratchev, 2023/03/23
Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- "), Kerin Millar, 2023/03/23
Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- "), alex xmb ratchev, 2023/03/23
Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- "),
alex xmb ratchev <=
Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- "), Bipul kumar, 2023/03/23
- Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- "), Greg Wooledge, 2023/03/23
- Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- "), Bipul kumar, 2023/03/23
- Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- "), alex xmb ratchev, 2023/03/23
Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- "), Kerin Millar, 2023/03/23
Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- "), Greg Wooledge, 2023/03/23
Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- "), alex xmb ratchev, 2023/03/23
Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- "), Bipul kumar, 2023/03/23
- Prev by Date:
Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- ")
- Next by Date:
Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- ")
- Previous by thread:
Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- ")
- Next by thread:
Re: whats wrong with (( a = 8 , a > 4 && a -= 2 || a-- )) , bash: ((: a = 8 , a > 4 && a -= 2 || a-- : attempted assignment to non-variable (error token is "-= 2 || a-- ")
- Index(es):