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

dpkg-query --show, invalid output when package is not found, and executed within a bash script.



The following shows an unexpected behaviour of the query output directly to the console screen, as oppose to what was intended in the bash script. The following 2 bash script examples, will probably explain the bug better. 

(the following was tested in ubuntu 12.04LTS)
----------------------------------------
[expected.sh]
#!/bin/bash
IPT_PACK_STATE="$(dpkg-query --show bash)"
echo "O_O : you should not be seeing anything before this line"
echo "> $IPT_PACK_STATE"

[output]
$bash expected.sh
O_O : you should not be seeing anything before this line
> bash 4.2-2ubuntu2
----------------------------------------
[unexpected.sh]
#!/bin/bash
IPT_PACK_STATE="$(dpkg-query --show theseAintTheDroidsYourLookingFor)"
echo "O_O : you should not be seeing anything before this line"
echo "> $IPT_PACK_STATE"

[output]
$bash unexpected.sh
No packages found matching theseAintTheDroidsYourLookingFor.
O_O : you should not be seeing anything before this line
>
----------------------------------------

In the second case, the variable is returned a blank, while the "No package found" output goes directly to console screen. If this is however intentional behaviour or design, perhaps adding a note to the '--help' section would facilitate others who intended to use this command within a shell script (for automation purposes =P )

PS: Im sending this email, as I am unable to find the bug tracker for the package directly =x

Reply to: