/usr/bin/yodl2whatever is in yodl 4.02.00-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | #!/bin/bash
# Don't hack the executable script by hand. Rather, reconfigure your
# YODL package and do "make -C scripts clean; make -C scripts install".
############################################################## Some variables.
# What are the allowed destination formats? Corresponding .yo files must
# exist in system-wide include directory (e.g. in /usr/local/lib/yodl)!
FORMATS="html latex man ms sgml txt xml"
verbose=no
# Internal Use Only: redefine yodl's path by setting an environment variable
[ "$YODL_BIN" == "" ] && YODL_BIN=/usr/bin
YODL=${YODL_BIN}/yodl
YODLPOST=${YODL_BIN}/yodlpost
######################################################### Print msg to stderr.
chat()
{
echo "$@" 1>&2
}
######################################################### Print error and die.
error()
{
chat "$@"
if [ "${keep_intermediate}" != "1" ] ; then
rm -f ${intermediate}.idx ${intermediate}
fi
exit 1
}
################################################################## Usage info.
usage()
{
cat << ENDUSAGE 1>&2
Yodl2whatever for `$YODL --version`
Usage: yodl2whatever [OPTION]... FILE
Where:
yodl2....: Specifies the conversion, the first part of the program name
is always yodl2, the second part is the destination format, one
of $FORMATS
Options:
Run "yodl" without arguments to see the Yodl-specific options.
Additional options:
--no-warnings: By default, yodl will warn for suspected macro calls. To
suppress these warnings, specify the --no-warnings flag
--intermediate=<file>: Most yodl conversions require the Yodl
post-processor to process Yodl's output. The temporary file
used for this is removed by default. If it should be
retained then this option can be used to specify the name
of the intermediate file presented to yodlpost.
This converter supplies the name of the macrofile that suits the conversion,
and makes sure that the output goes to the same name as the input file but
with the right extension. E.g., "yodl2html file" will read "file.yo" and write
"file.html".
ENDUSAGE
exit 1
}
####################################################### Run a command or exit.
run()
{
if [ "$verbose" = "yes" ]; then
echo running "$*"
fi
eval $* || error "$1 indicates failure!"
}
############################################################# Start of script.
# [ ! -x $YODL ] && echo "Yodl converter ($YODL) missing" && exit 1
# Do we have arguments at all?
if [ -z "$1" ] ; then
usage
fi
# Determine basename of this program.
base=`basename $0`
# Determine the options, using getopt(1). See its man-page
getopt -T > /dev/null
if [ "$?" == "4" ] ; then
# Rich man's getopt.
TEMP=`getopt -o D:d:ghi:I:kl:Lm:n:o:p:r:tVvWw \
--long define:,definemacro:,help,include:,index:,keep-ws,live-data:\
--long messages:,max-nested-files:,output:,preload:,max-replacements:\
--long trace,version,no-warnings,verbose,warranty,warn,intermediate:\
--long legacy-include:\
-- "$@"`
else
# Poor man's getopt. Only single-char flags supported.
TEMP=`getopt D:d:ghi:I:kl:m:n:o:p:r:tVvWw -- "$@"`
fi
if [ $? != 0 ] ; then echo "getopt error in $base" ; exit 1 ; fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"
while true
do
case "$1" in
(-w|--warn)
;;
(--no-warnings)
nowarn=1;
;;
(--intermediate)
intermediate=$2
keep_intermediate=1
shift
echo Intermediate file: ${intermediate}
;;
(-o|--output)
output="$2"
shift
;;
(-v|--verbose)
optionlist="$optionlist $1"
verbose=yes
;;
(-h|-k|-L|-t|-V|-W)
optionlist="$optionlist $1"
;;
(--help|--keep-ws|--legacy-include|--trace|--version|--warranty)
optionlist="$optionlist $1"
;;
(-D|-d|-i|-I|-m|-n|-p|-r)
echo $1 and $2
optionlist="$optionlist $1 $2"
shift
;;
(--define|--definemacro|--include|--index)
optionlist="$optionlist $1='$2'"
shift
;;
(--live-data|-l)
shift
;;
(--messages|--max-nested-files|--output|--preload|--max-replacements)
optionlist="$optionlist $1='$2'"
shift
;;
(--)
shift
break
;;
esac
shift
done
[ "${keep_intermediate}" == "1" ] || intermediate=`mktemp yodlXXXXXXXXXX`
[ "${nowarn}" == "1" ] || optionlist="-w $optionlist"
# Determine destination format.
dest=`IFS=2; set $base; echo $2`
# Check that format is one that we know.
found=no
for f in $FORMATS ; do
if [ $f = $dest ] ; then
found=yes
FORMAT=$f
break
fi
done
if [ $found = no ] ; then
chat "Unknown destination format $dest. You can convert from yodl to:"
chat $FORMATS
error "Use e.g. yodl2$f for a conversion from YODL to $f."
fi
# Found an output file?
if [ -z "$output" ] ; then
input=${!#}
output=${input%%.yo}.$dest
fi
[ ! -x $YODLPOST -o ! -x $YODL ] &&
echo "$base: can't proceed: \`$YODL' and/or \`$YODLPOST' missing" &&
exit 1
# Run YODL
run $YODL $optionlist -o ${intermediate} $dest $*
# See if there's a (need to use the) post-processor.
if [ -s ${intermediate}.idx ] ; then
run $YODLPOST ${intermediate}.idx ${intermediate} $output
else
chat "No post-processing required for this $FORMAT conversion"
run mv ${intermediate} $output
fi
if [ "${keep_intermediate}" != "1" ] ; then
rm -f ${intermediate}.idx ${intermediate}
fi
|