|
From: | Kerin Millar |
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 16:43:30 +0000 |
On Thu, 23 Mar 2023 21:36:38 +0530 Bipul kumar <bipul.opensource@gmail.com> wrote: > Let me explain here > The -= operator performs a compound subtraction and assignment operation, > which modifies the value of the variable on the left-hand side of the > operator. > Also it looks within a logical expression like this a -= 2 , Bash does not > allow any left side effects to occur. > So in order to make it work as it insists bash to perform in an isolated > subshell only a - = 2 NO ANY OTHER LOGICAL EXPRESSION Because it's a There are no subshells involved at any juncture. Perhaps you are confusing the use of parentheses inside an arithmetic expression with the (list) compound command? -- Kerin Millar
[Prev in Thread] | Current Thread | [Next in Thread] |