aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/grofftest.sh28
1 files changed, 16 insertions, 12 deletions
diff --git a/test/grofftest.sh b/test/grofftest.sh
index ca1aa71d9..8c7240aa7 100644
--- a/test/grofftest.sh
+++ b/test/grofftest.sh
@@ -1,22 +1,26 @@
#!/bin/bash
-# iterates over specified directory, containing "\w+\.\d"-like files,
-# executes pandoc voer them and prints stderr on nonzero return code
+# iterates recursively over specified directory, tries to convert
+# man pages and prints to stderr on errors.
-if [ $# -ne 2 ]; then
+# if called with two arguments, the first is the path to pandoc,
+# and the second is the directory. if with one argument, it
+# is the directory, and pandoc is used from path.
+
+if [ $# -eq 2 ]; then
+ PANDOC=$1
+ DIR=$2
+elif [ $# -eq 1 ]; then
+ PANDOC=pandoc
+ DIR=$1
+else
echo "Not enough arguments"
exit 1
fi
-PANDOC=$1
-DIR=$2
-
$PANDOC --version > /dev/null || { echo "pandoc executable error" >&2 ; exit 1 ; }
-ls $2 | egrep "^.+\.[0-9].?$" | while read f ; do
- FILE="$DIR/$f"
- $PANDOC -f man -t native < $FILE 2>&1 > /dev/null
- if [ $? -ne 0 ]; then
- echo "Failed to convert $FILE"
- fi
+for f in `find "$DIR" -name '*.[0-9]'`; do
+ ( iconv -f utf8 -t utf8 $f 2>/dev/null || iconv -f latin1 -t utf8 $f ) | \
+ $PANDOC --resource-path "$DIR":. -f man -o /dev/null || echo "Failed to convert $f"
done