title: Unbound variable with bash script
body: <p>Im becoming desperate when debugging my script, I used some constructions recommended to me from my senior collegue and I dont know how to make it work properly.  </p>
  
  <pre><code> #!/bin/bash -x
  set -ueo pipefail
  exec &amp;&gt;/tmp/dq.log
  source ${BASH_SOURCE%/*}/env-prd.sh
  
  times=${2:-1}
  sleep=${3:-1}
  
  name="all-dq_hourly"
  
  
  fs_lock_file="/tmp/mwa/jobs/prd-${name}.lock"
  
  ( flock -n 200
      log="/var/log/mwa/prd/$(date +%Y-%m-%d)__${name}.log"
      for i in $(seq 1 $times); do
          if [[ ! -f /tmp/stop ]]; then
          couple commands
  
        fi
          sleep $sleep
      done
  
  ) 200&gt;"$fs_lock_file" | tee -a $log
  
  rm $fs_lock_file
  </code></pre>
  
  <p>From the execs , I can see there is an issue with unbound variable for the <code>tee -a $log</code> part, <code>couple commands</code> get executed allright. I tried to use backtics in the log path, but to no benefit. I suspect the same issue with fs_lock_file, but I havent fixed the logging first yet.<br>
  Can somebody open my eyes and tell me what Im missing? Im not able to make the script logging to path specified.</p>