title: Bash - problem with using unset variable in a script
body: <p>I have following code:</p>
  
  <pre><code>VAR1=""
  ANOTHER_VAR="$VAR1/path/to/file"
  ANOTHER_VAR_2="$VAR1/path/to/another/file"
  
  ...
  
  # getopts which reads params from command line and sets the VAR1
  </code></pre>
  
  <p>The problem is that setting the <code>VAR1</code> after <code>ANOTHER_VARs</code> are set makes their paths without the <code>VAR1</code> part. I can't move the <code>getopts</code> above those because the script is long and there are many methods which depends on the variables and on other methods. Any ideas how to solve this?</p>