From 033512b16a8afa44cd7ba3a25f8d91bf87092f2f Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Sat, 4 Jun 2011 22:52:15 +0200 Subject: display error when required executables are missing Signed-off-by: Florian Pritz --- fb.in | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/fb.in b/fb.in index 7fc71a9..1bafe74 100644 --- a/fb.in +++ b/fb.in @@ -26,6 +26,13 @@ CLIPBOARD="" EXITCODE=0 LIBDIR="@LIBDIR@" +require_executable() { + if ! type $1 >/dev/null; then + echo "Error: $1 not found. Please install." >&2 + exit 1 + fi +} + do_upload() { local EXTRA="" file="$1" @@ -46,9 +53,11 @@ do_upload() { fi if [ "$COMPRESS" = "1" ]; then + require_executable gzip gzip -c -- "$file" > "$TMPDIR/$basefilename.gz" file="$TMPDIR/$basefilename.gz" elif [ "$COMPRESS" = "2" ]; then + require_executable xz xz -c -- "$file" > "$TMPDIR/$basefilename.xz" file="$TMPDIR/$basefilename.xz" fi @@ -147,8 +156,10 @@ if [ "$DELETE" ] || [ "$GET" ]; then $LIBDIR/fb-helper d "$PASTEBIN/file/delete/$i" || EXITCODE=1 elif [ "$GET" ]; then if [ "$COMPRESS" = "1" ]; then + require_executable zcat $LIBDIR/fb-helper d "$PASTEBIN/$i" | zcat || EXITCODE=1 elif [ "$COMPRESS" = "2" ]; then + require_executable xzcat $LIBDIR/fb-helper d "$PASTEBIN/$i" | xzcat || EXITCODE=1 else $LIBDIR/fb-helper d "$PASTEBIN/$i" || EXITCODE=1 -- cgit v1.2.3-24-g4f1b