e.g. MUTT="mutt -F /my/config"
echo \'${1//\'/\'\\\'\'}\'
}
echo \'${1//\'/\'\\\'\'}\'
}
+function is_callable () {
+ read cmd args <<<$1
+ type -p $cmd >/dev/null
+}
+
# Check command-line arguments and STDIN
if tty -s || [ $# -ne 0 ] ; then
cat >&2 <<END
# Check command-line arguments and STDIN
if tty -s || [ $# -ne 0 ] ; then
cat >&2 <<END
fi
# check if mutt is installed
fi
# check if mutt is installed
-if ! type -p $MUTT >/dev/null ; then
+if ! is_callable $MUTT ; then
die "$MUTT is not in PATH, set MUTT variable"
fi
die "$MUTT is not in PATH, set MUTT variable"
fi
esac
# search for Message-ID in STDIN
esac
# search for Message-ID in STDIN
-if type -p $FORMAIL >/dev/null ; then
+if is_callable $FORMAIL ; then
msgid=$($FORMAIL -c -z -x Message-ID | head -n1)
msgid=$($FORMAIL -c -z -x Message-ID | head -n1)
-elif type -p $REFORMAIL >/dev/null ; then
+elif is_callable $REFORMAIL ; then
msgid=$($REFORMAIL -c -x Message-ID: | head -n1)
else
msgid=$(sed -n 's/^Message-ID:[ \t]*\(.*\)/\1/Ip' | head -n1)
msgid=$($REFORMAIL -c -x Message-ID: | head -n1)
else
msgid=$(sed -n 's/^Message-ID:[ \t]*\(.*\)/\1/Ip' | head -n1)