From 48a66495f18b080f3299260c8031dd9f7838c325 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Thu, 15 Jan 2015 23:28:30 +0100 Subject: [PATCH] Closes #6 - Check whether include-file exists and is readable. - Added variable $PIZZAFILE --- src/pizza | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/pizza b/src/pizza index 028d06b..33b7b67 100755 --- a/src/pizza +++ b/src/pizza @@ -6,6 +6,7 @@ PIZZAUSER=$(whoami) PIZZAART= PIZZARCV= PIZZASEND= +PIZZAFILE= PIZZAVERSION="v1.0.1" help() { @@ -64,6 +65,7 @@ done : ${PIZZAART:="pizza"} : ${PIZZASEND:="${PIZZAUSER}@${PIZZAHOST}"} +PIZZAFILE="${PIZZAINC}/${PIZZAART}" if [ ! $PIZZARCV ]; then echo "Argument '-m' and mailaddress needed!" @@ -71,5 +73,17 @@ if [ ! $PIZZARCV ]; then exit 1 fi -mail -s "${PIZZAUSER} sent you a ${PIZZAART} on ${PIZZAHOST}!" -S from=${PIZZASEND} ${PIZZARCV} < "${PIZZAINC}/${PIZZAART}" +if [ ! -f "${PIZZAFILE}" ]; then + echo "ASCII-art file ${PIZZAFILE} not found!" + echo "You may need to set \$PIZZAINC (the ASCII-art directory)." + exit 1 +fi + +if [ ! -r "${PIZZAFILE}" ]; then + echo "ASCII-art file ${PIZZAFILE} not readable!" + echo "You may need to set the read rights correctly." + exit 1 +fi + +mail -s "${PIZZAUSER} sent you a ${PIZZAART} on ${PIZZAHOST}!" -S from=${PIZZASEND} ${PIZZARCV} < "${PIZZAFILE}" exit 0