I did not describe my fix, I described the problem. Here is another
patch that removes the unnecessary greps. The redirection of stderr in
this patch to /dev/null is only to avoid having it go to console during
the compile.
It doesn't really matter if you have KDE installed or not, you can test
the fix by making it search for a pkg that you don't have installed.
pkg_info -xc 'SomePkgThatIsNotInstalled' > test.txt
<pkg not found error to stderr>
cat test.txt
<nothing>
pkg_info -xc 'SomePkgThatIsInstalled' > test.txt
<no output>
cat test.txt
<the pkg information>
So, pkg_info returns nothing to stderr if the pkg is not installed, and
returns the pkg information if the pkg is installed, thus the logic
reversal in the if statement.