From: Rafał Miłecki <ra...@milecki.pl>

This makes checking for packages easier.

Example:
$ opkg status blo0ckd; echo $?
254

Signed-off-by: Rafał Miłecki <ra...@milecki.pl>
---
 libopkg/opkg_cmd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libopkg/opkg_cmd.c b/libopkg/opkg_cmd.c
index 6547775..f82e10a 100644
--- a/libopkg/opkg_cmd.c
+++ b/libopkg/opkg_cmd.c
@@ -795,6 +795,7 @@ static int opkg_info_status_cmd(int argc, char **argv, int 
installed_only)
        pkg_t *pkg;
        char *pkg_name = NULL;
        conffile_list_t *cl;
+       int err;
 
        if (argc > 0) {
                pkg_name = argv[0];
@@ -806,11 +807,13 @@ static int opkg_info_status_cmd(int argc, char **argv, 
int installed_only)
        else
                pkg_hash_fetch_available(available);
 
+       err = -ENOENT;
        for (i = 0; i < available->len; i++) {
                pkg = available->pkgs[i];
                if (pkg_name && fnmatch(pkg_name, pkg->name, conf->nocase)) {
                        continue;
                }
+               err = 0;
 
                pkg_formatted_info(stdout, pkg);
 
@@ -831,7 +834,7 @@ static int opkg_info_status_cmd(int argc, char **argv, int 
installed_only)
        }
        pkg_vec_free(available);
 
-       return 0;
+       return err;
 }
 
 static int opkg_info_cmd(int argc, char **argv)
-- 
2.35.3


_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to