diff options
Diffstat (limited to 'markdown2html')
-rw-r--r-- | markdown2html | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/markdown2html b/markdown2html index d71e434b4..280c1cf90 100644 --- a/markdown2html +++ b/markdown2html @@ -1,11 +1,24 @@ #!/bin/sh -e # converts markdown to HTML +pathfind () { # portable which(1), code taken from Debian Developer's Reference + OLDIFS="$IFS" + IFS=: + for _p in $PATH; do + if [ -x "$_p/$*" ]; then + IFS="$OLDIFS" + return 0 + fi + done + IFS="$OLDIFS" + return 1 +} + for p in pandoc; do - which $p >/dev/null 2>&1 || { - echo >&2 "You need '$p' to use this program!" - exit 1 - } + pathfind $p || { + echo >&2 "You need '$p' to use this program!" + exit 1 + } done iconv -t utf-8 $* | pandoc $PANDOC_OPTS | iconv -f utf-8 |