git.iko.soy/typeable/pandoc
on master help sign in
Improve test/grofftest.sh.

Use --resource-path. Use iconv for latin1 man pages. Recurse into subdirectories.

commitc71fbb18e1655a19215e681ab9064e5e6212d11c authorJohn MacFarlane <jgm@berkeley.edu> dateFri 2 Nov 2018, 10:59 (8 years ago) parentc0e0ef1
1 file changed+16−12
test/grofftest.sh+16−12
test/grofftest.sh+16−12
@@ -1,22 +1,26 @@
11#!/bin/bash
22
3−# iterates over specified directory, containing "\w+\.\d"-like files,
4−# executes pandoc voer them and prints stderr on nonzero return code
3+# iterates recursively over specified directory, tries to convert
4+# man pages and prints to stderr on errors.
55
6−if [ $# -ne 2 ]; then
6+# if called with two arguments, the first is the path to pandoc,
7+# and the second is the directory. if with one argument, it
8+# is the directory, and pandoc is used from path.
9+
10+if [ $# -eq 2 ]; then
11+ PANDOC=$1
12+ DIR=$2
13+elif [ $# -eq 1 ]; then
14+ PANDOC=pandoc
15+ DIR=$1
16+else
717 echo "Not enough arguments"
818 exit 1
919fi
1020
11−PANDOC=$1
12−DIR=$2
13−
1421$PANDOC --version > /dev/null || { echo "pandoc executable error" >&2 ; exit 1 ; }
1522
16−ls $2 | egrep "^.+\.[0-9].?$" | while read f ; do
17− FILE="$DIR/$f"
18− $PANDOC -f man -t native < $FILE 2>&1 > /dev/null
19− if [ $? -ne 0 ]; then
20− echo "Failed to convert $FILE"
21− fi
23+for f in `find "$DIR" -name '*.[0-9]'`; do
24+ ( iconv -f utf8 -t utf8 $f 2>/dev/null || iconv -f latin1 -t utf8 $f ) | \
25+ $PANDOC --resource-path "$DIR":. -f man -o /dev/null || echo "Failed to convert $f"
2226done