title: VERBOSE environment in shell script
body: <p>I'm trying to write a Bash script, which compiles and runs all C files in the current directory. My Bash script is the following:</p>
  
  <pre><code>#!/bin/bash
  
  LIST="$(ls *.c)"
  echo "Compile all C source files"
  
  for f in $( ls *.c); do
      #echo "C file: $f"
      gcc $f -o "${f%.*}"
      ./"${f%.*}"
  
  done
  </code></pre>
  
  <p>Now, I'm trying to define a <code>VERBOSE</code> environment variable. If <code>VERBOSE</code> environment variable is set then my Bash script should display the command that is being used to compile the source file.</p>
  
  <p>How can I define such a <code>VERBOSE</code> environment variable in this Bash script?</p>
  
  <p>When verbose is defined my output should be like,</p>
  
  <pre><code>    Compiling all C source files:
      gcc copyfile.c -o copyfile
      ---- successful ----
      gcc haserror.c -o haserror
      haserror.c: In function ‘main’:
      haserror.c:9:10: warning: missing terminating " character
      printf("Hello !\n);
      ^
      haserror.c:9:10: error: missing terminating " character
      printf("Hello!\n);
      ^~~~~~~~~~~~~~~~~~~
      haserror.c:11:1: error: expected expression before ‘}’ token
      }
      ^
      haserror.c:11:1: error: expected ‘;’ before ‘}’ token
      gcc hello.c -o hello
      ---- successful ----
      gcc p005.c -o p002
      ---- successful ----
      gcc p103.c -o p101
      ---- successful ----
      gcc p102.c -o p105
      ---- successful ----
      ============
      5 C source files are compiled successfully.
      1 C source files have compilation error(s).
  
  **Otherwise, when my VERBOSE not defined, my output should be like**
  
  Compiling all C source files:
  haserror.c: In function ‘main’:
  haserror.c:9:10: warning: missing terminating " character
  printf("Hello!\n);
  ^
  haserror.c:9:10: error: missing terminating " character
  printf("Hello!\n);
  ^~~~~~~~~~~~~~~~~~~
  haserror.c:11:1: error: expected expression before ‘}’ token
  }
  ^
  haserror.c:11:1: error: expected ‘;’ before ‘}’ token
  ============
  5 C source files are compiled successfully.
  1 C source files have compilation error(s).
  </code></pre>