git.iko.soy/typeable/pandoc
on rc/test4 help sign in
typeable/pandoc/test/grofftest.sh
26 lines 780 B history raw
1#!/bin/bash
3# iterates recursively over specified directory, tries to convert
4# man pages and prints to stderr on errors.
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.
10if [ $# -eq 2 ]; then
11 PANDOC=$1
12 DIR=$2
13elif [ $# -eq 1 ]; then
14 PANDOC=pandoc
15 DIR=$1
16else
17 echo "Not enough arguments"
18 exit 1
19fi
21$PANDOC --version > /dev/null || { echo "pandoc executable error" >&2 ; exit 1 ; }
23for 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":"$(dirname $f)" -f man -o /dev/null || echo "Failed to convert $f"
26done