Index: Functions/OptionParser
===================================================================
RCS file: /sources/goboscripts/tools/Scripts/Functions/OptionParser,v
retrieving revision 1.3
diff -u -r1.3 OptionParser
--- Functions/OptionParser	13 Sep 2005 01:17:47 -0000	1.3
+++ Functions/OptionParser	23 Aug 2006 19:08:40 -0000
@@ -13,6 +13,8 @@
 #declare -a optionsStateList
 optionsListSize=0
 parsedArguments=0
+getoptShortList="h"
+getoptLongList="help"
 
 function Add_Option() {
    local i
@@ -31,6 +33,14 @@
    optionsShortList[$optionsListSize]="$3"
    optionsLongList[$optionsListSize]="$4"
    optionsDescriptionList[$optionsListSize]="$5"
+   if [ "$1" == "Entry" ]
+   then
+      getoptShortList="${getoptShortList}${3}:"
+      getoptLongList="${getoptLongList},${4}:"
+   else
+      getoptShortList="${getoptShortList}${3}"
+      getoptLongList="${getoptLongList},${4}"
+   fi
 }
 
 function Add_Option_Boolean() {
@@ -221,12 +231,24 @@
 }
 
 function Parse_Options() {
+   if [ -x $goboExecutables/getopt ]
+   then
+      echo "getopt -o $getoptShortList -l $getoptLongList -- $@"  >&2
+      parsedOptions=`echo "\`getopt -o $getoptShortList -l $getoptLongList -- $@\`" | sed 's/\(.*\)-- \(.*\)/\1\2/'`
+   else
+      parsedOptions="$@"
+   fi
+   echo $parsedOptions >&2
+   Parse_Options_Real $parsedOptions
+}
+
+function Parse_Options_Real() {
    local i
    savedOptions=("$@")
-   if [ "$1" = "--help" -o "$1" = "-h" ] || [ "$helpOnNoArguments" -a -z "$*" ]
+   if [ "$1" = "--help" -o "$1" = "-h" ] || [ "$helpOnNoArguments" -a \( -z "$*" -o "--" = "$*" \) ]
    then Show_Help
    fi
-   if [ "$1" = "--version" -o "$1" = "-v" ] || [ "$helpOnNoArguments" -a -z "$*" ]
+   if [ "$1" = "--version" -o "$1" = "-v" ] || [ "$helpOnNoArguments" -a \( -z "$*" -o "--" = "$*" \) ]
    then Show_Version
    fi
    if [ "$1" = "--list-options" ]
