[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#297668: 'apt-cache search': returns 'true' exit code when target not found



Package: apt
Version: 0.5.28.5
Severity: normal


Good:
	% apt-cache search debian > /dev/null ; echo $?
	0

Bad:
	% apt-cache search NoSuchStringAnywhere > /dev/null ; echo $?
	0

It'd be better if 'apt-cache search' returned a '1' when a 
search turns up nothing.  I've seen front-ends scripts that 
use code like this:

        result=`apt-cache search "$@"`
        if [ -z "$result" ] ; then
                echo "No results for \"$search_words\"" 
	fi

That is, hold the 'apt-cache' output in a file or variable,
then test if it's empty.  Proper error codes would allow:

	if result=`apt-cache search "$@"` ; then
		echo "No results for \"$search_words\"
	fi


Hope this helps...


-- Package-specific info:

-- System Information:
Debian Release: 3.1
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.9-1-686
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) (ignored: LC_ALL set to C)

Versions of packages apt depends on:
ii  libc6                       2.3.2.ds1-20 GNU C Library: Shared libraries an
ii  libgcc1                     1:3.4.3-9    GCC support library
ii  libstdc++5                  1:3.3.5-8    The GNU Standard C++ Library v3

-- no debconf information



Reply to: