title: Exit if in a script, do not exit if using a terminal/tty
body: <p>If the user is entering commands in a terminal, I want to echo an error statement, but I do not want the terminal to close, so I have this:</p>
  
  <pre><code>  if [[ "$fle" =~ [^a-zA-Z0-9] ]]; then
      echo "quicklock: lockname has invalid chars - must be alpha-numeric chars only."
      if [[ -t 1 ]]; then
          # if we are in a terminal just return, do not exit.
          return 1;
      else
          exit 1;
      fi
    fi
  </code></pre>
  
  <p>however the <code>if [[ -t 1 ]]; then</code> does not seem to work, the terminal window I am using just closes immediately, so I think <code>exit 1</code> is being called.</p>