The following commit has been merged in the master branch:
commit 3f252f654a8bc8fb33ab9484777d3dbe5725a6f5
Author: Niels Thykier <ni...@thykier.net>
Date:   Mon Mar 12 08:53:49 2012 +0100

    jh_lib.sh: Try to parse -O options
    
    Parse (and accept) known options passed via the -O paramater.  Unknown
    options are silently discarded (as before).
    
    Signed-off-by: Niels Thykier <ni...@thykier.net>

diff --git a/debian/changelog b/debian/changelog
index 07b7008..33e9bd6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -12,7 +12,9 @@ javatools (0.41) UNRELEASED; urgency=low
   [ Niels Thykier ]
   * Produce a better error message when a non-existent Jar file is
     passed to jh_manifest.
-       
+  * Try to parse arguments passed via -O for jh_lib.sh as regular
+    options, but ignore them if they are unknown.  Previously, -O
+    options was silently ignored.
        
  -- Sylvestre Ledru <sylves...@debian.org>  Fri, 24 Feb 2012 16:22:58 +0100
 
diff --git a/jh_lib.sh.in b/jh_lib.sh.in
index 0cb90f6..300f807 100644
--- a/jh_lib.sh.in
+++ b/jh_lib.sh.in
@@ -12,27 +12,30 @@ parseargs()
    ARGV=()
        debhelper=
    while [ -n "$1" ]; do
-      if [ "-V" = "$1" ] || [ "--version" = "$1" ]; then
+      ignore=no
+      arg="$1"
+      if [ "-O" = "${arg:0:2}" ] ; then
+         arg="${arg:2}"
+         ignore=yes
+      fi
+      if [ "-V" = "$arg" ] || [ "--version" = "$arg" ]; then
          echo "Javahelper Version $JAVATOOLS_VERSION"
          exit 0
-      elif [ "-h" = "$1" ] || [ "--help" = "$1" ]; then
+      elif [ "-h" = "$arg" ] || [ "--help" = "$arg" ]; then
          syntax
-      elif [ "--with" = "$1" ]; then
+      elif [ "--with" = "$arg" ]; then
                        debhelper=true
                        shift
-      elif [ "-O" = "${1:0:2}" ]; then
-          # -O from debhelper - we ignore that
-          :
-      elif [ "-" = "${1:1:1}" ]; then
+      elif [ "-" = "${arg:1:1}" ]; then
       # long opt
-         optn="`sed 's/^--\([^=]*\)\(=.*\)*$/\1/;s/-/_/g' <<< $1`"
+         optn="`sed 's/^--\([^=]*\)\(=.*\)*$/\1/;s/-/_/g' <<< $arg`"
          if [ -z "$optn" ] || ! echo $ARGS | sed 's/-/_/g' | grep $optn 
>/dev/null; then
-                               if [ -z "$debhelper" ]; then
-                                       echo "Invalid option: $optn"
-                                       syntax
-                               fi
+            if [ -z "$debhelper" -a "$ignore" != "yes" ]; then
+                echo "Invalid option: $optn"
+                syntax
+            fi
          fi
-         optv="`echo $1 | sed -n 's/^[^=]*=\(.*\)$/\1/p'`"
+         optv="`echo $arg | sed -n 's/^[^=]*=\(.*\)$/\1/p'`"
          if [ -z "$optv" ]; then
             optv=true
          fi
@@ -42,16 +45,16 @@ parseargs()
                        else
                                export opt_$optn="$optv"
                        fi
-      elif [ "-" = "${1:0:1}" ]; then
+      elif [ "-" = "${arg:0:1}" ]; then
       # short opt
-         optn="${1:1:1}"
+         optn="${arg:1:1}"
          if [ -z "$optn" ] || ! echo $ARGS | grep $optn >/dev/null; then
-                               if [ -z "$debhelper" ]; then
-                                       echo "Invalid option: $optn"
-                                       syntax
-                               fi
+            if [ -z "$debhelper" -a "$ignore" != "yes" ]; then
+                echo "Invalid option: $optn"
+                syntax
+            fi
          fi
-         optv="${1:2}"
+         optv="${arg:2}"
          if [ -z "$optv" ]; then
             optv=true
          fi
@@ -63,7 +66,7 @@ parseargs()
                        fi
       else
       # not-opt arg
-         ARGV[$ARGC]="$1"
+         ARGV[$ARGC]="$arg"
          ARGC=$(( $ARGC + 1 ))
       fi
       shift

-- 
UNNAMED PROJECT

_______________________________________________
pkg-java-commits mailing list
pkg-java-comm...@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

Reply via email to