[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How come math/arithmetic cannot work by set -x
From: |
Greg Wooledge |
Subject: |
Re: How come math/arithmetic cannot work by set -x |
Date: |
Fri, 12 Aug 2022 20:46:11 -0400 |
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
35
In this case, $((a * b)) was expanded to 35 before executing the variable
assignment, so that's what set -x shows. Similarly, "$c" was expanded
to 35, so set -x shows that as well.
What *exactly* were you expecting? We're all being forced to guess, and
it's obnoxious.