To illustrate my issue and questions consider two scripts.
#!/bin/sh test=1 echo $test
When I run Script1.sh from the command line directly via ./Script1.sh it produces the desired output.
However when I run Script2.sh which calls Script1.sh, instead I get the following error message:
Script2.sh: line 1: 1: command not found
It thinks that the integer 1 is a command for some odd reason?
I found a cheap work around which is to set a variable from the first script and pass it to the second script as a parameter but I would like to understand why this is failing.
Also, when I changed my variables value from 1 to “some text”, I would expect that my echo would print “some text” to the screen. But when I call Script2.sh (which ultimately just calls Script1.sh) it doesn’t print the echo to the screen. Why is that, and how do I resolve it so I can see the echo output the same as if I would have called Script1.sh directly?
Any advice would be greatly appreciated.