[pacman-dev] Fwd: [PATCH] Hack to detect Pacman-command-no-found error

Martin Panter vadmium+patch at gmail.com
Tue Oct 30 19:54:29 EDT 2012


[Resending after subscribing my address. If this works perhaps a note
should be added saying you have to subscribe to be able to send to the
list?]
Original [patch] in case it gets garbled:
https://github.com/vadmium/pacman-arch/commit/0a71ece.patch

If the spirit of the change is appropriate but you’re not happy about
using the ”test” command, I’m happy to learn how to use the
Bash-specific way with double square brackets. Or someone who already
knows can translate it :)

>From 0a71ece90951894953ffd7bae741d69af927bf3f Mon Sep 17 00:00:00 2001
From: Martin Panter <vadmium à gmail·com>
Date: Thu, 18 Oct 2012 06:31:07 +0000
Subject: [PATCH] Hack to detect Pacman-command-no-found error

Bash also uses exit code 127 for command-not-found errors, which can occur if
we lose access to the command given by $PACMAN. For instance after invoking
/etc/profile, $PATH may be reset.
---
 scripts/makepkg.sh.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index d387b7d..307ceeb 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -895,7 +895,7 @@ check_deps() {
        pmout=$(run_pacman -T "$@")
        ret=$?

-       if (( ret == 127 )); then #unresolved deps
+       if test "$ret" -eq 127 -a -n "$pmout"; then #unresolved deps
                printf "%s\n" "$pmout"
        elif (( ret )); then
                error "$(gettext "'%s' returned a fatal error (%i):
%s")" "$PACMAN"
"$ret" "$pmout"
--
1.7.12


More information about the pacman-dev mailing list