title: How to print to the terminal if there is no flag present
body: <p>so in my code its structured like this</p>
  
  <pre><code>USAGE="Usage: ./MyProject.sh [-o &lt;output-file&gt;] &lt;guests&gt;"
  </code></pre>
  
  <p>Where -o is a flag option that allows us to print in the file name of names of guests.
  For instance i insert this into the terminal</p>
  
  <p>Example 1</p>
  
  <pre><code>./MyProject.sh -o GuestNames list
  </code></pre>
  
  <p>The program should create a file called GuestNames and store whatever is in the file name in list into GuestNames. IF however, I input this following command</p>
  
  <p>Example 2:      </p>
  
  <pre><code>./MyProject.sh -o list
  </code></pre>
  
  <p>It should just print the following names of people in the list into the terminal.</p>
  
  <p>I already have the code down (like it can detect file name list, etc.) , What i'm having trouble with is printing it out of the terminal if there is no flag present as seen on example 2.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>outfile=  #default: print to stdout
  function user{
  while getopts ":o:" arg; do
  case $arg in
   o) outfile=$OPTARG #tests the outfile to see if there is a flag
    ;;
   #Other cases and more code below but won't effect anything
  }
  
  if ( outfile= $OPTARG); then
  $OPTARG &gt; $outfile
  print_guests &gt;$outfile #added for the guests to be print
  else
  print_guests #function that converts the list into an array and prints out guests
  fi 
  </code></pre>
  
  <p>The error i get is "$outfile: ambiguous redirect" since i think its trying to direct the outfield into an empty string and not trying to print out to the terminal. If you can please help me i'll appreciate it!</p>