I am trying to understand how the one-time variable assignment needs to be done correctly in Bash. Please consider the following two examples, where I was expecting to get the same result in Bash:
unset Var
Var=123 echo $Var
# prints nothing
I now edit the file test.sh with the following content:
#!/bin/bash
echo $Var
and execute:
unset Var
Var=123 source test.sh
# prints 123
Can somebody please explain why there is different behavior in these two examples?
Thanks!