|
From: | Bipul kumar |
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 21:23:34 +0530 |
Hi Alex, It's failing because, what you are doing is compound assignment a -= 2 which needs to be inside parentheses. It works for me. (( a = 8 , a > 4 && (a -= 2) || a-- )) $ echo $a 6 source https://www.gnu.org/software/bash/manual/bash.html search "compound assignment" Respectfully, Bipul PUBLIC KEY <http://ix.io/1nWf> 97F0 2E08 7DE7 D538 BDFA B708 86D8 BE27 8196 D466 ** Please excuse brevity and typos. ** On Thu, Mar 23, 2023 at 4:03 PM 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 = > > is it ? :)) > > greets >
[Prev in Thread] | Current Thread | [Next in Thread] |