libmakepkg/executable: don't rely on scoped value of $ret to flag outcomes

Elsewhere, we return 1 if a library dropin fails, and when running
functions in a loop, we use `|| ret=1` to preserve scope. This ensures
the return value of the function remains useful in isolation. Do the
same thing here as well.

Drop trivial function which wraps a dropin that also uses $ret, since
it's no longer needed.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Eli Schwartz 2018-11-27 23:00:36 -05:00 committed by Allan McRae
parent 65e09705d3
commit 9f1b735d76
9 changed files with 12 additions and 14 deletions

View file

@ -38,7 +38,7 @@ check_software() {
local ret=0
for func in ${executable_functions[@]}; do
$func
$func || ret=1
done
return $ret

View file

@ -31,7 +31,7 @@ executable_ccache() {
if check_buildoption "ccache" "y"; then
if ! type -p ccache >/dev/null; then
error "$(gettext "Cannot find the %s binary required for compiler cache usage.")" "ccache"
ret=1
return 1
fi
fi
}

View file

@ -31,7 +31,7 @@ executable_distcc() {
if check_buildoption "distcc" "y"; then
if ! type -p distcc >/dev/null; then
error "$(gettext "Cannot find the %s binary required for distributed compilation.")" "distcc"
ret=1
return 1
fi
fi
}

View file

@ -31,7 +31,7 @@ executable_fakeroot() {
if check_buildenv "fakeroot" "y" && (( EUID > 0 )); then
if ! type -p fakeroot >/dev/null; then
error "$(gettext "Cannot find the %s binary.")" "fakeroot"
ret=1
return 1
fi
fi
}

View file

@ -28,6 +28,8 @@ source "$LIBRARY/util/option.sh"
executable_functions+=('executable_gpg')
executable_gpg() {
local ret=0
if [[ $SIGNPKG == 'y' ]] || { [[ -z $SIGNPKG ]] && check_buildenv "sign" "y"; }; then
if ! type -p gpg >/dev/null; then
error "$(gettext "Cannot find the %s binary required for signing packages.")" "gpg"
@ -41,4 +43,6 @@ executable_gpg() {
ret=1
fi
fi
return $ret
}

View file

@ -31,7 +31,7 @@ executable_gzip() {
if check_option "zipman" "y"; then
if ! type -p gzip >/dev/null; then
error "$(gettext "Cannot find the %s binary required for compressing man and info pages.")" "gzip"
ret=1
return 1
fi
fi
}

View file

@ -31,7 +31,7 @@ executable_pacman() {
if (( ! NODEPS || DEP_BIN || RMDEPS || INSTALL )); then
if [[ -z $PACMAN_PATH ]]; then
error "$(gettext "Cannot find the %s binary required for dependency operations.")" "$PACMAN"
ret=1
return 1
fi
fi
}

View file

@ -31,7 +31,7 @@ executable_strip() {
if check_option "strip" "y"; then
if ! type -p strip >/dev/null; then
error "$(gettext "Cannot find the %s binary required for object file stripping.")" "strip"
ret=1
return 1
fi
fi
}

View file

@ -49,7 +49,7 @@ get_vcsclient() {
printf "%s\n" "$client"
}
check_vcs_software() {
executable_vcs() {
local netfile all_sources all_deps deps ret=0
if (( SOURCEONLY == 1 )); then
@ -101,9 +101,3 @@ check_vcs_software() {
return $ret
}
executable_vcs() {
if ! check_vcs_software; then
ret=1
fi
}