title: Multiple option arguments using getopts (bash)
body: <p>I am trying to process command line arguments using getopts in bash. One of the requirements is for the processing of an arbitrary number of option arguments (without the use of quotes).</p>
  
  <p>1st example (only grabs the 1st argument)</p>
  
  <pre><code>madcap:~/projects$ ./getoptz.sh -s a b c
  -s was triggered
  Argument: a
  </code></pre>
  
  <p>2nd example (I want it to behave like this but without needing to quote the argument"</p>
  
  <pre><code>madcap:~/projects$ ./getoptz.sh -s "a b c"
  -s was triggered
  Argument: a b c
  </code></pre>
  
  <p>Is there a way to do this?</p>
  
  <p>Here's the code I have now:</p>
  
  <pre><code>#!/bin/bash
  while getopts ":s:" opt; do
      case $opt in
      s) echo "-s was triggered" &gt;&amp;2
         args="$OPTARG"
         echo "Argument: $args"
         ;;
     \?) echo "Invalid option: -$OPTARG" &gt;&amp;2
         ;;
      :) echo "Option -$OPTARG requires an argument." &gt;&amp;2
         exit 1
         ;;
      esac
  done
  </code></pre>