title: How do I set an option to force-bypass confirmations in my bash script?
body: <p>I'm looking to add the option <code>--force</code> or <code>-f</code> to make it so that [Y/n] confirmation prompts don't appear.</p>
  
  <p>I tried this:</p>
  
  <pre><code>if [[ $1 = "--name" ]] || [[ $1 = "-n" ]]; then
  if [ -d "$2" ]; then # directory operand validity check
  if [[ $3 == "--force" ]]; then
    read -r -p "'$2' will be sorted by file name. Continue? [Y/n] " response
  fi
      if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]] || [[ $response == "" ]] || [[ $3 == "--force" ]]; then
  
               ... code ...
  
      elif [[ $response =~ ^([nN][oO]|[nN])$ ]]; then
        echo Aborting...
      else
        echo
        echo Invalid response \'$response\' -- Aborting...
      fi
  else
    echo invalid directory operand \'$2\'
  fi
  </code></pre>
  
  <p>but that still prompted the question.</p>
  
  <p>Putting an if statement around the prompt and all of the outcomes wouldn't be ideal either, since I would have to copy the <em>Yes</em> outcome outside of it and that's too dodgy, even for me.</p>