Skip to content

Commit

Permalink
Return exit status 1 for additional cases
Browse files Browse the repository at this point in the history
The combination of -e and package name patterns was not possible
before, therefore there is no precedent whether to return 0 or 1
if there is no match. If -e alone was used, the exit status was 0
even if there was no match, and this behavior is retained.

For the new situation that the package names matched but the
condition failed for all matches, 1 is now returned to indicate
that no output is generated in a query for specific packages.
  • Loading branch information
stesser authored and bapt committed Aug 18, 2021
1 parent da1a478 commit 1cec8b5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/query.c
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ exec_query(int argc, char **argv)
i++;
} while (i < argc);

if (nprinted == 0 && condition_sql == NULL && retcode == EXIT_SUCCESS) {
if (nprinted == 0 && match != MATCH_ALL && retcode == EXIT_SUCCESS) {
/* ensure to return a non-zero status when no package
were found. */
retcode = EXIT_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion tests/frontend/query.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ EOF
atf_check \
-o empty \
-e empty \
-s exit:0 \
-s exit:1 \
pkg query -e "%#r>0" "%n: %rn %rv %ro" plop

atf_check \
Expand Down

0 comments on commit 1cec8b5

Please sign in to comment.