[pacman-dev] [PATCH] pacman: better handle -F when file is not found
Error messages are now printed. Pacman now returns 1 if any of the files queried are not found. --- src/pacman/files.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/pacman/files.c b/src/pacman/files.c index 8e518486..c4351114 100644 --- a/src/pacman/files.c +++ b/src/pacman/files.c @@ -115,7 +115,6 @@ static int files_search(alpm_list_t *syncs, alpm_list_t *targets, int regex) { if(regex) { if(regcomp(®, targ, REG_EXTENDED | REG_NOSUB | REG_ICASE | REG_NEWLINE) != 0) { - /* TODO: error message */ goto notfound; } } @@ -174,13 +173,20 @@ static int files_search(alpm_list_t *syncs, alpm_list_t *targets, int regex) { regfree(®); } + if(found) { + continue; + } + notfound: - if(!found) { - ret++; + ret = 1; + if(regex) { + pm_printf(ALPM_LOG_ERROR, _("no files match '%s'\n"), targ); + } else { + pm_printf(ALPM_LOG_ERROR, _("no package owns '%s'\n"), targ); } } - return 0; + return ret; } static void dump_file_list(alpm_pkg_t *pkg) { -- 2.23.0
On 09/09/19 at 05:49pm, morganamilo wrote:
Error messages are now printed. Pacman now returns 1 if any of the files queried are not found. --- src/pacman/files.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/pacman/files.c b/src/pacman/files.c index 8e518486..c4351114 100644 --- a/src/pacman/files.c +++ b/src/pacman/files.c @@ -115,7 +115,6 @@ static int files_search(alpm_list_t *syncs, alpm_list_t *targets, int regex) {
if(regex) { if(regcomp(®, targ, REG_EXTENDED | REG_NOSUB | REG_ICASE | REG_NEWLINE) != 0) { - /* TODO: error message */ goto notfound;
...
notfound: - if(!found) { - ret++; + ret = 1; + if(regex) { + pm_printf(ALPM_LOG_ERROR, _("no files match '%s'\n"), targ);
"no files match" isn't really a great error message if the real problem is that the regex failed to even compile.
participants (2)
-
Andrew Gregory
-
morganamilo