aboutsummaryrefslogtreecommitdiff
path: root/markdown2pdf
diff options
context:
space:
mode:
authorroktas <roktas@788f1e2b-df1e-0410-8736-df70ead52e1b>2006-11-12 21:17:06 +0000
committerroktas <roktas@788f1e2b-df1e-0410-8736-df70ead52e1b>2006-11-12 21:17:06 +0000
commit2763382dd803916e34e6575904147d7e3594a7f6 (patch)
treec87b10e109f87a7336b9b4022ef2da6314757290 /markdown2pdf
parent8e5f3e684c13a4b48d0ed24a15560f2631fc8e93 (diff)
downloadpandoc-2763382dd803916e34e6575904147d7e3594a7f6.tar.gz
Replace which(1) in all wrappers with 'pathfind', a POSIX-compliant shell
function. Expand tabs to four spaces. git-svn-id: https://pandoc.googlecode.com/svn/trunk@94 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'markdown2pdf')
-rw-r--r--markdown2pdf53
1 files changed, 33 insertions, 20 deletions
diff --git a/markdown2pdf b/markdown2pdf
index 4af407fb7..59c0ba634 100644
--- a/markdown2pdf
+++ b/markdown2pdf
@@ -1,34 +1,47 @@
#!/bin/sh
# converts markdown to latex, then uses latex to make a PDF
+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 pdflatex; 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
outfile=
for option; do
if [ -n "$prev" ]; then
- eval "$prev=\$option"
- prev=
- shift
- continue
+ eval "$prev=\$option"
+ prev=
+ shift
+ continue
fi
optarg=$(expr "x$option" : 'x[^=]*=\(.*\)')
case $option in
-h | --h | --help )
- help=1
- shift ;;
+ help=1
+ shift ;;
-o | --o | --output )
- prev=outfile
- shift ;;
+ prev=outfile
+ shift ;;
-o=* | --o=* | --output=* )
- outfile=$optarg
- shift ;;
+ outfile=$optarg
+ shift ;;
-* ) echo >&2 "$0: unknown option: $option; aborting"
- exit 1 ;;
+ exit 1 ;;
* ) break ;;
esac
done
@@ -41,9 +54,9 @@ done
infile=$1
if [ -z "$outfile" ]; then
if [ -n "$infile" ]; then
- outfile=${infile%.*}.pdf
+ outfile=${infile%.*}.pdf
else
- outfile='stdin.pdf' # input is STDIN, since no argument given
+ outfile='stdin.pdf' # input is STDIN, since no argument given
fi
fi
@@ -61,9 +74,9 @@ pandoc $PANDOC_OPTS -w latex -s | \
iconv -f utf-8 > $TEMP/$BASE.tex && (
cd $TEMP
if ! pdflatex -interaction=batchmode $BASE.tex >/dev/null 2>&1; then
- echo >&2 "LaTeX errors:"
- cat >&2 $BASE.log
- exit 1
+ echo >&2 "LaTeX errors:"
+ cat >&2 $BASE.log
+ exit 1
fi
) || exit $?