View Single Post
Old 2021-10-02, 16:20   #1
EdH
 
EdH's Avatar
 
"Ed Hall"
Dec 2009
Adirondack Mtns

459910 Posts
Default BASH script segment won't work in larger script

I have the following in a BASH script:
Code:
      echo "c4 is $c4 and am is $am"
      c4m=$(../../yafu/yafu "expr($c4*$am)" -silent)
      echo "c4 is $c4 and c4m is $c4m"
It doesn't work anywhere* in that 800+ line script:
Code:
c4 is -2293531595601876 and am is 3
c4 is -2293531595601876 and c4m is no variable indicator (@): interpreting batchfile lines as input expressions
eof; done processing batchfile
But, if I try the exact copy/pasted lines in a small test script (adding in the required values):
Code:
#!/bin/bash

c4=-2293531595601876
am=3
      echo "c4 is $c4 and am is $am"
      c4m=$(../../yafu/yafu "expr($c4*$am)" -silent)
      echo "c4 is $c4 and c4m is $c4m"
it works exactly as expected:
Code:
c4 is -2293531595601876 and am is 3
c4 is -2293531595601876 and c4m is -6880594786805628
I'm (pretty) sure this isn't a YAFU issue, so I'm posting here.

* I have tried these lines in two functions and in various locations in the main body of the larger script with no success. The scripts are located in the same directory.

All thoughts welcome. . .
EdH is offline   Reply With Quote