title: in Bash you can set -x to enable debugging, is there any way to know if that has been set or not from within the script?
body: <p>When making complex bash scripts, I will often use the command:</p>
  
  <pre class="lang-sh prettyprint-override"><code>set -x
  </code></pre>
  
  <p>to enable me to debug the script if it is not behaving.</p>
  
  <p>However I have some UI functions that generate a LOT of garbage in debug mode, so I would like to wrap them in a conditional along the lines of:</p>
  
  <pre><code>ui~title(){
      DEBUG_MODE=0
      if [ set -x is enabled ] # this is the bit I don't know how to do
      then
          # disable debugging mode for this function as it is not required and generates a lot of noise
          set +x
          DEBUG_MODE=1
      fi
  
      # my UI code goes here
  
      if [ "1" == "$DEBUG_MODE" ]
      then
          # re enable debugging mode here
          set -x
      fi
  }
  </code></pre>
  
  <p>The problem is that I can't figure out how to know if debug mode is enabled or not.</p>
  
  <p>I'm assuming it is possible, I just can't seem to find it despite lots of searching.</p>
  
  <p>Thanks in advance for any tips</p>