<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -52,45 +52,35 @@ function usage {
   sqlite3 &quot;$database&quot; &quot;SELECT buffername FROM buffer WHERE buffername != '' ORDER BY buffername&quot; | column
   echo
   echo &quot; PATTERN        a simple pattern, use * for wildcard matching&quot;
-  echo
-  # TODO:
-  echo &quot;NOTE: order of options is not exchangable, i.e. first -u, then -b then pattern...&quot;
 }
 
 if [[ &quot;$database&quot; == &quot;&quot; || ! -f &quot;$database&quot; ]]; then
   echo &quot;BAD DATABASE: $database&quot;
   echo
   usage
-  exit
+  exit 1
 fi
 
-if [[ &quot;$1&quot; == &quot;-u&quot; ]]; then
-  shift 1
-  if [[ &quot;$1&quot; == &quot;&quot; ]]; then
-    usage
-    exit
+while getopts &quot;u:b:&quot; flag
+do
+  if [[ &quot;$flag&quot; == &quot;u&quot; ]]; then
+    user=&quot;$OPTARG&quot;
+  elif [[ &quot;$flag&quot; == &quot;b&quot; ]]; then
+    buffer=&quot;$OPTARG&quot;
   fi
-  user=&quot;$1&quot;
-  shift 1
-fi
+done
 
-if [[ &quot;$1&quot; == &quot;-b&quot; ]]; then
-  shift 1
-  if [[ &quot;$1&quot; == &quot;&quot; ]]; then
-    usage
-    exit
-  fi
-  buffer=&quot;$1&quot;
-  shift 1
-fi
+shift $(($OPTIND - 1))
 
-if [[ &quot;$1&quot; == &quot;&quot; &amp;&amp; &quot;$user&quot; == &quot;&quot; &amp;&amp; &quot;$buffer&quot; == &quot;&quot; ]]; then
+pattern=&quot;$1&quot;
+
+if [[ &quot;$pattern&quot; == &quot;&quot; &amp;&amp; &quot;$user&quot; == &quot;&quot; &amp;&amp; &quot;$buffer&quot; == &quot;&quot; ]]; then
+  echo &quot;pattern required&quot;
+  echo
   usage
-  exit
+  exit 1
 fi
 
-pattern=&quot;$1&quot;
-
 # escape '
 pattern=${pattern//\'/\'\'}
 # escape %</diff>
      <filename>quassellog</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>f4760d3c67b491c201b33cff423429073d56243f</id>
    </parent>
  </parents>
  <author>
    <name>Milian Wolff</name>
    <email>mail@milianw.de</email>
  </author>
  <url>http://github.com/milianw/shell-helpers/commit/b50e4118c04267c7debe284d202290bf4142a635</url>
  <id>b50e4118c04267c7debe284d202290bf4142a635</id>
  <committed-date>2009-09-02T09:26:52-07:00</committed-date>
  <authored-date>2009-09-02T09:26:52-07:00</authored-date>
  <message>use getopts for argument evaluation</message>
  <tree>63087bcf1b1deb96447c2727d4d044ed27424e77</tree>
  <committer>
    <name>Milian Wolff</name>
    <email>mail@milianw.de</email>
  </committer>
</commit>
