28 lines
510 B
Bash
28 lines
510 B
Bash
|
THIS=${0##*/}
|
||
|
|
||
|
NEWLINE='
|
||
|
'
|
||
|
|
||
|
err () { echo "$*" | fold -s -w ${COLUMNS:-110} >&2; }
|
||
|
errn () { printf "$*" | fold -s -w ${COLUMNS:-110} >&2; }
|
||
|
|
||
|
# Portable which(1).
|
||
|
pathfind () {
|
||
|
oldifs="$IFS"; IFS=':'
|
||
|
for _p in $PATH; do
|
||
|
if [ -x "$_p/$*" ] && [ -f "$_p/$*" ]; then
|
||
|
IFS="$oldifs"
|
||
|
return 0
|
||
|
fi
|
||
|
done
|
||
|
IFS="$oldifs"
|
||
|
return 1
|
||
|
}
|
||
|
|
||
|
for p in pandoc $REQUIRED; do
|
||
|
pathfind $p || {
|
||
|
err "You need '$p' to use this program!"
|
||
|
exit 1
|
||
|
}
|
||
|
done
|