On Thu, Jun 30, 2016 at 07:04:10PM +0200, Fabiano Fidêncio wrote: > According to `man osinfo-query`: "The exit status will be 0 if matching > entries were found, or 1 if not matches were found". So, let's adapt the > program in order to match the manual. > > Also, this patch was written keeping the current behavior about printing > the Short ID, Name, Version, ID table. > > Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1351718 > > Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx> > --- > tools/osinfo-query.c | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/tools/osinfo-query.c b/tools/osinfo-query.c > index 66f49e2..48e792f 100644 > --- a/tools/osinfo-query.c > +++ b/tools/osinfo-query.c > @@ -331,6 +331,9 @@ static gboolean print_results_text(OsinfoList *list, > } > g_print("\n"); > > + if (tmp == NULL) > + goto end; > + You could add a short /* No match /* comment before this if() or the goto. Acked-by: Christophe Fergeau <cfergeau@xxxxxxxxxx> Christophe > while (tmp) { > OsinfoEntity *entity = OSINFO_ENTITY(tmp->data); > > @@ -338,9 +341,10 @@ static gboolean print_results_text(OsinfoList *list, > tmp = tmp->next; > } > > + ret = TRUE; > > +end: > g_list_free(entities); > - ret = TRUE; > // cleanup: > return ret; > } > @@ -458,7 +462,13 @@ gint main(gint argc, gchar **argv) > > osinfo_list_add_filtered(results, entities, filter); > > - print_results_text(results, labels, sortKey); > + if (!print_results_text(results, labels, sortKey)) { > + /* > + * The os wasn't found, no need to print an error, > + * just be sure to return EXIT_FAILURE. > + */ > + goto error; > + } > > ret = EXIT_SUCCESS; > > -- > 2.7.4 > > _______________________________________________ > Libosinfo mailing list > Libosinfo@xxxxxxxxxx > https://www.redhat.com/mailman/listinfo/libosinfo
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ Libosinfo mailing list Libosinfo@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libosinfo