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

dpkg -I, --search, -s exit status



I deliberately decided to have -s (--status) and -S (--search) give a
zero exit status if a package or file asked for didn't exist.  After
all, you can tell from whether any (appropriate) output was produced
whether the item was found.  Perhaps it should be changed to give 1 if
at least one of the mentioned items is not found.

Dale Scheetz produces the following piece of Perl code to try to show
that -I gives a zero exit status for (say) nonexistent archives:
 $command=`dpkg -I $ARGV[0]`;
 if ( "$CHILD_ERROR" eq "256" ) { system("echo 'ERROR'"); }
 else { system("echo 'No error'"); }

This is wrong, of course.  He's comparing the wait status with 256,
which corresponds to an exit status of 1, and claiming that there is
no error if it didn't match.  However, dpkg gives an exit status of 2
for this error:

-chiark:~> dpkg -I /spong; echo $?
dpkg-deb: failed to read archive `/spong': No such file or directory
2
-chiark:~> perl -e 'system("dpkg -I /spong"); print "wait code $?\n";'
dpkg-deb: failed to read archive `/spong': No such file or directory
wait code 512
-chiark:~>

I'm surprised that noone spotted this before.  If you want to test for
all child error exit codes in Perl you need to compare $? with 0.

Ian.

--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-devel-REQUEST@lists.debian.org . Trouble? e-mail to Bruce@Pixar.com


Reply to: