From a6ce111ab2fd71e0c13f5e165addeb18a4125f1e Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 20 Jan 2014 00:47:41 -0500 Subject: librefetch: improve error handling --- src/librefetch/librefetch | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index c723721..87a55cd 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -18,12 +18,12 @@ # You should have received a copy of the GNU General Public License # along with Parabola. If not, see . -. $(librelib conf.sh) -. libremessages +. $(librelib conf) +. $(librelib messages) +setup_traps declare -r tempdir="$(mktemp -d --tmpdir ${0##*/}.XXXXXXXXXXX)" -cleanup() { rm -rf -- "$tempdir"; } -trap cleanup EXIT +trap "rm -rf -- $(printf '%q' "$tempdir")" EXIT cmd=${0##*/} usage() { @@ -91,10 +91,15 @@ main() { local BUILDFILEDIR="${BUILDFILE%/*}" if [[ -f "${BUILDFILEDIR}/SRCBUILD" ]]; then BUILDFILE="${BUILDFILEDIR}/SRCBUILD" - srcbuild="$(modified_srcbuild "$BUILDFILE")" - else - srcbuild="$(modified_pkgbuild "$BUILDFILE")" fi + if [[ ! -f "$BUILDFILE" ]]; then + error "%s does not exist." "$BUILDFILE" + exit 1 + fi + case "$BUILDFILE" in + */SRCBUILD) srcbuild="$(modified_srcbuild "$BUILDFILE")";; + *) srcbuild="$(modified_pkgbuild "$BUILDFILE")";; + esac makepkg="$(modified_makepkg "$(which makepkg)")" # Mode: checksums ###################################################### -- cgit v1.2.2