24 | 24 |
error()
|
25 | 25 |
{
|
26 | 26 |
chat "$@"
|
|
27 |
if [ "${keep_intermediate}" != "1" ] ; then
|
|
28 |
rm -f ${intermediate}.idx ${intermediate}
|
|
29 |
fi
|
27 | 30 |
exit 1
|
28 | 31 |
}
|
29 | 32 |
|
|
45 | 48 |
Additional options:
|
46 | 49 |
--no-warnings: By default, yodl will warn for suspected macro calls. To
|
47 | 50 |
suppress these warnings, specify the --no-warnings flag
|
48 | |
--tmp=<path>: By default, the temporary file is written in the /tmp
|
49 | |
directory. Specify an alternate directory using
|
50 | |
--tmp = path-to-alternate-tmp-directory
|
51 | |
--unique-output: By default, yodl will use a temporary output file that
|
52 | |
is rewritten at each new yodl-invokation. If that's not
|
53 | |
what you want, specify the --unique-output flag, which
|
54 | |
will use the process-id as part of the temporary output
|
55 | |
file. This file is NOT removed when the yodl-conversion
|
56 | |
fails.
|
|
51 |
--intermediate=<file>: Most yodl conversions require the Yodl
|
|
52 |
post-processor to process Yodl's output. The temporary file
|
|
53 |
used for this is removed by default. If it should be
|
|
54 |
retained then this option can be used to specify the name
|
|
55 |
of the intermediate file presented to yodlpost.
|
57 | 56 |
|
58 | 57 |
This converter supplies the name of the macrofile that suits the conversion,
|
59 | 58 |
and makes sure that the output goes to the same name as the input file but
|
|
76 | 75 |
############################################################# Start of script.
|
77 | 76 |
|
78 | 77 |
# [ ! -x $YODL ] && echo "Yodl convertor ($YODL) missing" && exit 1
|
79 | |
|
80 | |
# define the default temporary directory
|
81 | |
tmpdir=/tmp
|
82 | 78 |
|
83 | 79 |
# Do we have arguments at all?
|
84 | 80 |
if [ -z "$1" ] ; then
|
|
95 | 91 |
TEMP=`getopt -o D:d:ghi:I:kl:m:n:o:p:r:tVvWw \
|
96 | 92 |
--long define:,definemacro:,help,include:,index:,keep-ws,live-data:\
|
97 | 93 |
--long messages:,max-nested-files:,output:,preload:,max-replacements:\
|
98 | |
--long trace,version,no-warnings,unique-output,verbose,warranty,warn\
|
99 | |
--long tmp:\
|
|
94 |
--long trace,version,no-warnings,verbose,warranty,warn,intermediate\
|
100 | 95 |
-- "$@"`
|
101 | 96 |
else
|
102 | 97 |
# Poor man's getopt. Only single-char flags supported.
|
|
116 | 111 |
(--no-warnings)
|
117 | 112 |
nowarn=1;
|
118 | 113 |
;;
|
119 | |
(--unique-output)
|
120 | |
unique=-$$;
|
121 | |
echo Unique output: ${unique}
|
122 | |
;;
|
123 | |
(--tmp)
|
124 | |
tmpdir="$2"
|
125 | |
shift
|
|
114 |
(--intermediate)
|
|
115 |
intermediate=$2
|
|
116 |
keep_intermediate=1
|
|
117 |
shift
|
|
118 |
echo Intermediate file: ${intermediate}
|
126 | 119 |
;;
|
127 | 120 |
(-o|--output)
|
128 | 121 |
output="$2"
|
|
159 | 152 |
shift
|
160 | 153 |
done
|
161 | 154 |
|
162 | |
[ "$nowarn" == "1" ] || optionlist="-w $optionlist"
|
|
155 |
[ "${keep_intermediate}" == "1" ] || intermediate=`mktemp yodlXXXXXXXXXX`
|
|
156 |
|
|
157 |
[ "${nowarn}" == "1" ] || optionlist="-w $optionlist"
|
163 | 158 |
|
164 | 159 |
# Determine destination format.
|
165 | 160 |
dest=`IFS=2; set $base; echo $2`
|
|
191 | 186 |
exit 1
|
192 | 187 |
|
193 | 188 |
# Run YODL
|
194 | |
run $YODL $optionlist -o ${tmpdir}/yodl-${USER}${unique} $dest $*
|
|
189 |
run $YODL $optionlist -o ${intermediate} $dest $*
|
195 | 190 |
|
196 | 191 |
# See if there's a (need to use the) post-processor.
|
197 | |
if [ -s ${tmpdir}/yodl-${USER}${unique}.idx ] ; then
|
198 | |
run $YODLPOST ${tmpdir}/yodl-${USER}${unique}.idx \
|
199 | |
${tmpdir}/yodl-${USER}${unique} $output
|
|
192 |
if [ -s ${intermediate}.idx ] ; then
|
|
193 |
run $YODLPOST ${intermediate}.idx ${intermediate} $output
|
|
194 |
if [ "${keep_intermediate}" != "1" ] ; then
|
|
195 |
rm -f ${intermediate}.idx ${intermediate}
|
|
196 |
fi
|
200 | 197 |
else
|
201 | 198 |
chat "No post-processing required for this $FORMAT conversion"
|
202 | |
run mv ${tmpdir}/yodl-${USER}${unique} $output
|
203 | |
fi
|
|
199 |
run mv ${intermediate} $output
|
|
200 |
fi
|