[pacman-dev] [PATCH] pacman: return 1 when -F <target> has no results

morganamilo morganamilo at gmail.com
Sat Oct 12 19:12:03 UTC 2019


---

This is basically my V2 for "pacman: better handle -F when file is not
found".

With the freeze coming up and me not having that much time to do pacman
stuff, this is the best I've got right now.

I have been thinking about the original patch and I don't really like it
much any more.

One issue is that -Qi and -Si give error messages when there's no match,
but -Qs and -Ss do not. So for consistency sake should -Fx not give an
error message?

Also -Qs and -Ss both fail to report when an error occurs during
search. So just like how -F currently does not report regex errors,
neither does -Q and -S.

Lastly there is the issue of how to handle regex errors in -F? Because
the search is done in the front end, the error does not come from alpm.
We could just do `alpm_strerror(ALPM_ERR_REGEX)` to reuse alpm's
error message. Or maybe move it into the backend along side
alpm_db_search?

I'll leave all this open to discussion and hope this small patch is
mostly agreeable so it can make it in this release.
---
 src/pacman/files.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/pacman/files.c b/src/pacman/files.c
index 8e518486..af11666d 100644
--- a/src/pacman/files.c
+++ b/src/pacman/files.c
@@ -176,11 +176,11 @@ static int files_search(alpm_list_t *syncs, alpm_list_t *targets, int regex) {
 
 notfound:
 		if(!found) {
-			ret++;
+			ret = 1;
 		}
 	}
 
-	return 0;
+	return ret;
 }
 
 static void dump_file_list(alpm_pkg_t *pkg) {
-- 
2.23.0


More information about the pacman-dev mailing list