title: Running a bash script with mandatory arguments
body: <p>I want my bash script to be working only when I type</p>
  
  <pre><code>bash.sh --subj directoryname --input filename --all
  </code></pre>
  
  <p><code>--subj</code>, <code>--input</code>, and <code>--all</code> are all required to make the script work, and the <code>--all</code> argument does not require any input. </p>
  
  <p>If either <code>--subj</code> or <code>--input</code> is missing, I want the following message to be printed:</p>
  
  <p>Please provide both directory name and file name.</p>
  
  <p>If <code>--all</code> argument is missing, I want to print:</p>
  
  <pre><code>Please use --all option.
  </code></pre>
  
  <p>I fix a script from Github using <code>optparse</code>. </p>
  
  <pre><code>source optparse.bash
  optparse.define short=s long=subj desc="subject name" variable=subj
  optparse.define short=i long=input desc="The file to process" variable=input
  optparse.define short=a long=all desc="all option" variable=all value=true default=false
  
  source $(optparse.build)
  if [ "$subj" == "" ]; then
     echo "ERROR: Please provide a directory name"
     exit 1
  fi
  
  if [ "$input" == "" ]; then
     echo "ERROR: Please provide an input"
     exit 1
  fi
  
  if [ "$all" == "" ]; then
     echo "ERROR: Please use the all option"
     exit 1
  fi
  </code></pre>
  
  <p><a href="https://github.com/nk412/optparse/blob/master/sample_head.sh" rel="nofollow">https://github.com/nk412/optparse/blob/master/sample_head.sh</a></p>
  
  <p>Using this code, it does say please provide a directory name when I missed --subj or -input. but when I miss all, it does not say any error. do you know why is that?</p>