Merge branch '6checkPIZZAINC' into 'master'
PIZZAINC check Checks now PIZZAINC for existence and readability before evaluating it.
This commit is contained in:
commit
4a9b62b2c6
1 changed files with 15 additions and 1 deletions
16
src/pizza
16
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
|
||||
|
|
Loading…
Reference in a new issue