Re: How come math/arithmetic cannot work by set -x

2022-08-13 Thread Chet Ramey
On 8/12/22 8:22 PM, Dennis Williamson wrote: set -x; unset a; b=2; c=7; ((a = b + c)); echo "$a $b $c"; set +x + unset a + b=2 + c=7 + (( a = b + c )) + echo '9 2 7' 9 2 7 + set +x without the dollar signs doesn't. "Within an expression, shell variables may also be referenced by name wit

Re: How come math/arithmetic cannot work by set -x

2022-08-13 Thread Chet Ramey
On 8/12/22 7:27 PM, Budi wrote: How come math/arithmetic ((i=k+l)) cannot make use of set -x If you're talking about what I think you are, because that's not how `set -x' works. It's the same reason that k=2+3 echo $(( $k*5 )) echo $(( k*5 )) produces two different numbers. -- ``The lyf so

Re: How come math/arithmetic cannot work by set -x

2022-08-12 Thread Greg Wooledge
On Sat, Aug 13, 2022 at 06:51:04AM +0700, Budi wrote: > It doesn't work means no use on set -x, no value is shown set -x shows the command being executed, with arguments expanded. unicorn:~$ cat foo #!/bin/bash set -x a=5 b=7 c=$((a * b)) echo "$c" unicorn:~$ ./foo + a=5 + b=7 + c=35 + echo 35

Re: How come math/arithmetic cannot work by set -x

2022-08-12 Thread Lawrence Velázquez
On Fri, Aug 12, 2022, at 7:40 PM, Dennis Williamson wrote: > It works for me. What are you expecting? > > It would help if you show what you're doing, the result you're getting and > what you expect instead. I'm guessing that instead of, for example % bash -xc 'a="(x=1)" b="2*3"; ((a+b))'

Re: How come math/arithmetic cannot work by set -x

2022-08-12 Thread Dennis Williamson
On Fri, Aug 12, 2022 at 6:51 PM Budi wrote: > It doesn't work means no use on set -x, no value is shown > > On 8/13/22, Dennis Williamson wrote: > > On Fri, Aug 12, 2022, 6:28 PM Budi wrote: > > > >> How come math/arithmetic ((i=k+l)) cannot make use of set -x > >> > >> Please help.. > >> (so a

Re: How come math/arithmetic cannot work by set -x

2022-08-12 Thread Budi
It doesn't work means no use on set -x, no value is shown On 8/13/22, Dennis Williamson wrote: > On Fri, Aug 12, 2022, 6:28 PM Budi wrote: > >> How come math/arithmetic ((i=k+l)) cannot make use of set -x >> >> Please help.. >> (so annoying). >> > > > It works for me. What are you expecting? > >

Re: How come math/arithmetic cannot work by set -x

2022-08-12 Thread Dennis Williamson
On Fri, Aug 12, 2022, 6:28 PM Budi wrote: > How come math/arithmetic ((i=k+l)) cannot make use of set -x > > Please help.. > (so annoying). > It works for me. What are you expecting? It would help if you show what you're doing, the result you're getting and what you expect instead. "It doesn'

How come math/arithmetic cannot work by set -x

2022-08-12 Thread Budi
How come math/arithmetic ((i=k+l)) cannot make use of set -x Please help.. (so annoying).