From 3ed8fc8784496722af85b6ec2ff5120c75db84dc Mon Sep 17 00:00:00 2001 From: roktas Date: Sun, 12 Nov 2006 12:11:25 +0000 Subject: 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 --- markdown2pdf | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'markdown2pdf') 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 . -- cgit v1.2.3