Package: dlocate
Version: 1.02
Severity: normal

Example:

    % dlocate -lsbin bash > /dev/null ; echo $?
    1

More general:

    # count how many times a '1' error code happens with 100 packages   
    % for f in `dglob | head -n 100` ; do dlocate -lsbin $f > /dev/null ; echo 
$? ; done | sort | uniq -c
        100 1

First I'd thought the trouble might be error codes
from a 'grep' or 'sed' filter:

    % grep -nA 11 "'\-lsbin')" `which dlocate` | tail -n 12
    386:            '-lsbin')
    387-                if [ -s $DPKG_INFO/$PKG.list ] ; then
    388-                    dlocate -L $PKG | \
    389-                    xargs -r ls -lLd 2> /dev/null | \
    390-                    grep -v "^[^-]" | \
    391-                    grep -E '^-.{2,8}[xs]' | \
    392-                    sed -e 's/.* \//\//' | \
    393-                    xargs -r ls -1
    394-                else
    395-                    echo Package $PKG not installed or $PKG.list is 
empty. >&2
    396-                fi
    397-                ;;

But that can't be so, as the code from lines #388-393 returns
the expected error code:

    PKG=dash
    dlocate -L $PKG | xargs -r ls -lLd 2> /dev/null | grep -v "^[^-]" | grep -E 
'^-.{2,8}[xs]' | sed -e 's/.* \//\//' | xargs -r ls -1 ; echo $?
    /bin/dash
    0

...and yet that code also fails to return an error code for bogus
packages:

    PKG=dish
    dlocate -L $PKG | xargs -r ls -lLd 2> /dev/null | grep -v "^[^-]" | grep -E 
'^-.{2,8}[xs]' | sed -e 's/.* \//\//' | xargs -r ls -1 ; echo $?
    Package dish not installed or dish.list is empty.
    0

The problem seems to be that the above quoted '-lsbin'
routine doesn't set the '$result' variable (line #415 is the last line
of code in 'dlocate'):

    grep -n result `which dlocate`
    282:    result=$?
    288:    result=$?
    295:    result=$?
    303:    result=$?
    310:    result=$?
    415:test -n "$result" && exit $result

So: line #415 sees no "$result"  and returns a '1', and the '-lsbin'
routine always returns a '0'. Other surrounding routines seem to have
this problem as well.

Attached is a patch for the '-lsbin' routine only.


HTH...

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.31-1-686 (SMP w/1 CPU core)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) (ignored: LC_ALL set to C)
Shell: /bin/sh linked to /bin/dash

Versions of packages dlocate depends on:
ii  dctrl-tools [grep-dctrl]      2.14       Command-line tools to process Debi
ii  dpkg                          1.15.3.1   Debian package management system
ii  perl                          5.10.1-8   Larry Wall's Practical Extraction 

dlocate recommends no packages.

dlocate suggests no packages.

-- no debconf information
--- /usr/bin/dlocate    2009-06-02 21:29:06.000000000 -0400
+++ /tmp/dlocate        2010-01-08 19:05:41.000000000 -0500
@@ -391,8 +391,10 @@
                     grep -E '^-.{2,8}[xs]' | \
                     sed -e 's/.* \//\//' | \
                     xargs -r ls -1
+                    result=$?
                 else
                     echo Package $PKG not installed or $PKG.list is empty. >&2
+                    result=1
                 fi
                 ;;
 

Reply via email to