diff options
author | roktas <roktas@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2006-11-12 12:11:25 +0000 |
---|---|---|
committer | roktas <roktas@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2006-11-12 12:11:25 +0000 |
commit | 3ed8fc8784496722af85b6ec2ff5120c75db84dc (patch) | |
tree | c372051cd084ff53a7996a1a54e3c1c54d847b2e /markdown2pdf | |
parent | 69e23af8e4198dc4e308935855662248a31c6dc2 (diff) | |
download | pandoc-3ed8fc8784496722af85b6ec2ff5120c75db84dc.tar.gz |
Portability fixes and various cleanups in wrapper scripts:
+ Fix the tests at the header of wrappers. which(1) doesn't behave as
expected on some systems. We should only assume that it's pretty widely
available (for example, it's a builtin in csh) and we should only rely on
its exit code by ignoring its output.
+ Replace 'echo -n' with 'printf' as the latter is recommended.
+ In markdown2pdf script, '--suffix' and '--backup' options of mv(1) appear
to be GNU-ism. Apply a workaround.
+ Wrap some long lines to fit in an 80-column screen.
+ Remove spaces at the line ends.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@92 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'markdown2pdf')
-rw-r--r-- | markdown2pdf | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/markdown2pdf b/markdown2pdf index eba975436..4af407fb7 100644 --- a/markdown2pdf +++ b/markdown2pdf @@ -1,14 +1,12 @@ #!/bin/sh # converts markdown to latex, then uses latex to make a PDF -[ -n "$(which pandoc)" ] || { - echo >&2 "You need 'pandoc' to use this program!" - exit 1 -} -[ -n "$(which pdflatex)" ] || { - echo >&2 "You need 'pdflatex' to use this program!" - exit 1 -} +for p in pandoc pdflatex; do + which $p >/dev/null 2>&1 || { + echo >&2 "You need '$p' to use this program!" + exit 1 + } +done outfile= for option; do @@ -58,8 +56,9 @@ TEMP=${TMPDIR-/tmp}/markdown2pdf.$$ trap "status=$?; rm -rf $TEMP; exit $status" 0 INT mkdir -p $TEMP -iconv -t utf-8 $infile | pandoc $PANDOC_OPTS -w latex -s | iconv -f utf-8 > $TEMP/$BASE.tex -( +iconv -t utf-8 $infile | \ +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:" @@ -71,12 +70,13 @@ iconv -t utf-8 $infile | pandoc $PANDOC_OPTS -w latex -s | iconv -f utf-8 > $TEM is_target_exists= if [ -f $outfile ]; then is_target_exists=1 + mv -f $outfile $outfile~ fi -mv --suffix=~ --backup $TEMP/$BASE.pdf $outfile +mv -f $TEMP/$BASE.pdf $outfile -echo -n >&2 "Created $outfile" +printf "Created $outfile" >&2 [ -z "$is_target_exists" ] || { - echo -n >&2 " (previous file has been backed up as '$outfile~')" + printf " (previous file has been backed up as '$outfile~')" >&2 } echo >&2 . |