/usr/bin/refdbjade is in refdb-clients 1.0.2-1.
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 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | #!/bin/bash
# refdbjade - creates formatted output from a DocBook SGML source with
# RefDB bibliography data
# Markus Hoenicka <markus@mhoenicka.de> 1999-09-02
# OPTIONS: -d (stylesheet) -h (invoke help), -i (variable),
#          -j (jade command-line arguments), -t (output format)
# relies on these external programs: (open)jade, jadetex, pdfjadetex, dvips
### start user-customizable section
# the Jade/OpenJade command
myjade="/usr/bin/openjade"
# the SGML declaration
sgmldecl="/usr/share/refdb/declarations/docbook.dcl"
# the RefDB master catalog
refdbcat="/usr/share/refdb/refdb.cat"
### end user-customizable section
# some defaults
outformat="tex"
# this allows to include or ignore marked sections in the SGML file
jadeincludearg=""
# this allows to pass additional options to (open)jade
jadeargs=""
# this allows to set variable values on the (open)jade command line
jadevariablearg=""
# this is an optional prefix for output filenames
prefix=""
htmlprefixarg=""
# the path of the global configuration file
globalconfig="/etc/refdb/refdbjaderc"
# determine configuration files
if [ ! -r "$globalconfig" ] && [ -n "$REFDBLIB" ]; then
    globalconfig=$REFDBLIB/refdbjaderc
fi
userconfig=$HOME/.refdbjaderc
if [ -n "$globalconfig" ] && [ -r "$globalconfig" ]; then
    allconfigs=$globalconfig
fi
if [ -r "$userconfig" ]; then
    allconfigs=$allconfigs" "$userconfig
fi
# read the settings in the configure file(s)
for config in $allconfigs; do
    while read refdbvar refdbval; do
	if [ -n "$refdbvar" ]; then
	    if [ $refdbvar = jade_args ]; then
		jadeargs=$refdbval
	    fi
	    if [ $refdbvar = jade_includearg ]; then
		jadeincludearg=$jadeincludearg" -i "$refdbval
	    fi
	    if [ $refdbvar = jade_variable ]; then
		jadevariablearg=$jadevariablearg" -V "$refdbval
	    fi
	    if [ $refdbvar = outformat ]; then
		outformat=$refdbval
	    fi
	fi
    done < $config
done
# read the command line options
while getopts ":hI:j:p:s:t:v:" opt; do
  case $opt in
    h  ) echo "creates formatted output from a DocBook SGML source with RefDB bibliography data"
	 echo 'usage: refdbjade [-h] [-I name] [-j jade-args] [-p prefix] [-s stylesheet] [-t outformat] [-v variable[=value]] file1 [file2...]'
	 echo "Options: -h print this help and exit"
	 echo "         -I set name of INCLUDE section in OpenJade"
	 echo "         -j additional command-line options for OpenJade"
	 echo "         -p use prefix for output filenames"
	 echo "         -s select stylesheet"
	 echo "         -t select the output format. Possible values are html,"
	 echo "            rtf, dvi, pdf, ps, tex, tps, tpdf. Default is tex."
	 echo "         -v set variable to #t or to value for OpenJade"
	 exit 0 ;;
    I  ) jadeincludearg=$jadeincludearg" -i "$OPTARG;;
    j  ) jadeargs=$OPTARG;;
    p  ) prefix=$OPTARG;;
    s  ) stylesheet=$OPTARG;;
    t  ) outformat=$OPTARG;;
    v  ) jadevariablearg=$jadevariablearg" -v "$OPTARG;;
    \? ) echo 'usage: refdbjade [-h] [-I name] [-j jade-args] [-p prefix] [-s stylesheet] [-t outformat] [-v variable[=value]] file1 [file2...]'
	 echo 'type refdbjade -h to invoke help'
	 exit 1;;
  esac
done
# correct the index so the filename argument is always $1
shift $(($OPTIND - 1))
# test for valid arguments
if [ ! $outformat = html ] && [ ! $outformat = htmlr ] && [ ! $outformat = rtf ] && [ ! $outformat = dvi ] && [ ! $outformat = pdf ] && [ ! $outformat = ps ] && [ ! $outformat = tex ] && [ ! $outformat = tps ] && [ ! $outformat = tpdf ]; then
  echo "specify one of 'html', 'htmlr', 'rtf', 'dvi', 'pdf', 'ps', 'tex', 'tps', 'tpdf' with the -t option"
  exit 1
fi
# assemble stylesheet invocation
htmlsheet=$stylesheet\#html
printsheet=$stylesheet\#print
# Unfortunately TeX does not indicate with an appropriate return
# value whether an additional run is necessary. To determine whether
# we need an additional tex run, we can look at file.aux and compare
# it to the previous run (we could also try to parse the output of tex
# on stdout, but that does not seem to be easier). So we create a
# backup of the existing file.aux (we create an empty file.aux if it
# does not exist) by appending the process number to the filename. We
# then run jadetex/pdfjadetex once which will create a new
# file.aux. We compare this version with the previous version and run
# jadetex until diff returns 0 indicating no differences. diff --brief
# prevents that the differences are listed on the screen. Somewhat
# kludgy, but it works. We might consider adding a counter to break
# infinite loops.
# loop over all filename arguments
for filename in $*; do
  # on Win32-cygwin, the native Win32 TeX tools want the DOS path, and
  # the cygwin TeX tools accept this too
  case $(uname) in
    CYGWIN*) mypath=$(cygpath -w $filename);;
    *) mypath=$filename;;
  esac
  # extract the basename from the argument
  basename=${filename%.*}
  # extract basename w/o full path
  sbasename=${basename##*/}
  if [ -n "$prefix" ]; then
    # put the prefix in place
    outbasename=$prefix$sbasename
    htmloutarg="-V %html-prefix%="$prefix
    rtfoutarg="-o "$outbasename.rtf
    texoutarg="-o "$outbasename.tex
    pdfoutarg="-o "$outbasename.pdf
    # get the name only - output files will be generated in PWD
    myfile=$prefix${filename##*/}
  else
    htmloutarg=""
    rtfoutarg="-o "$sbasename.rtf
    texoutarg="-o "$sbasename.tex
    pdfoutarg="-o "$sbasename.pdf
    # get the name only - output files will be generated in PWD
    myfile=${filename##*/}
  fi
  # the jade calls contain the -c option to make sure the stylesheets
  # are found even if the user was too lazy to set SGML_CATALOG_FILES
  case $outformat in
    html ) $myjade $jadeargs $jadevariablearg $htmloutarg $jadeincludearg -t sgml -c $refdbcat -d $htmlsheet $sgmldecl $mypath
	   if [ $? -ne 0 ]; then
	     exit 1
	   fi;;
    htmlr ) $myjade $jadeargs $jadevariablearg $htmloutarg $jadeincludearg -t sgml-raw -c $refdbcat -d $htmlsheet $sgmldecl $mypath
	   if [ $? -ne 0 ]; then
	     exit 1
	   fi;;
    rtf  ) $myjade $jadeargs $jadevariablearg $rtfoutarg $jadeincludearg -t rtf -c $refdbcat -d $printsheet $sgmldecl $mypath
	   if [ $? -ne 0 ]; then
	     exit 1
	   fi;;
    dvi  ) $myjade $jadeargs $jadevariablearg $texoutarg $jadeincludearg -t tex -V tex-backend -c $refdbcat -d $printsheet $sgmldecl $mypath
	   if [ $? -ne 0 ]; then
	     exit 1
	   fi
	   if [ ! -e ${myfile%.*}.aux ]; then
             touch ${myfile%.*}.aux
	   fi
	   cp ${myfile%.*}.aux ${myfile%.*}.aux.$$
	   jadetex ${myfile%.*}.tex
	   if [ $? -ne 0 ]; then
	     exit 1
	   fi
           until diff --brief ${myfile%.*}.aux ${myfile%.*}.aux.$$; do
	     cp ${myfile%.*}.aux ${myfile%.*}.aux.$$
	     jadetex ${myfile%.*}.tex
	   done
	   rm ${myfile%.*}.aux.$$;;
    pdf  ) $myjade $jadeargs $jadevariablearg $texoutarg $jadeincludearg -t tex -V tex-backend -c $refdbcat -d $printsheet $sgmldecl $mypath
	   if [ $? -ne 0 ]; then
	     exit 1
	   fi
           if [ ! -e ${myfile%.*}.aux ]; then
	     touch ${myfile%.*}.aux
	   fi
	   cp ${myfile%.*}.aux ${myfile%.*}.aux.$$
	   pdfjadetex ${myfile%.*}.tex
	   if [ $? -ne 0 ]; then
	     exit 1
	   fi
	   until diff --brief ${myfile%.*}.aux ${myfile%.*}.aux.$$; do
	     cp ${myfile%.*}.aux ${myfile%.*}.aux.$$
	     pdfjadetex ${myfile%.*}.tex
	   done
	   rm ${myfile%.*}.aux.$$;;
    ps   ) $myjade $jadeargs $jadevariablearg $texoutarg $jadeincludearg -t tex -V tex-backend -c $refdbcat -d $printsheet $sgmldecl $mypath
	   if [ $? -ne 0 ]; then
	     exit 1
	   fi
           if [ ! -e ${myfile%.*}.aux ]; then
	     touch ${myfile%.*}.aux
	   fi
	   cp ${myfile%.*}.aux ${myfile%.*}.aux.$$
	   jadetex ${myfile%.*}.tex
	   if [ $? -ne 0 ]; then
	     exit 1
	   fi
           until diff --brief ${myfile%.*}.aux ${myfile%.*}.aux.$$; do
	     cp ${myfile%.*}.aux ${myfile%.*}.aux.$$
	     jadetex ${myfile%.*}.tex
	   done
	   rm ${myfile%.*}.aux.$$
	   dvips -o ${myfile%.*}.ps ${myfile%.*}.dvi
	   if [ $? -ne 0 ]; then
	     exit 1
	   fi;;
    tex  ) $myjade $jadeargs $jadevariablearg $texoutarg $jadeincludearg -t tex -V tex-backend -c $refdbcat -d $printsheet $sgmldecl $mypath
	   if [ $? -ne 0 ]; then
	     exit 1
	   fi;;
    tps  ) if [ ! -e ${myfile%.*}.aux ]; then
	     touch ${myfile%.*}.aux
	   fi
	   cp ${myfile%.*}.aux ${myfile%.*}.aux.$$
	   jadetex ${myfile%.*}.tex
	   if [ $? -ne 0 ]; then
	     exit 1
	   fi
	   until diff --brief ${myfile%.*}.aux ${myfile%.*}.aux.$$; do
	     cp ${myfile%.*}.aux ${myfile%.*}.aux.$$
	     jadetex ${myfile%.*}.tex
	   done
	   rm ${myfile%.*}.aux.$$
	   dvips -o ${myfile%.*}.ps ${myfile%.*}.dvi
	   if [ $? -ne 0 ]; then
	     exit 1
	   fi;;
    tpdf ) if [ ! -e ${myfile%.*}.aux ]; then
	     touch ${myfile%.*}.aux
	   fi
	   cp ${myfile%.*}.aux ${myfile%.*}.aux.$$
	   pdfjadetex ${myfile%.*}.tex
	   if [ $? -ne 0 ]; then
	     exit 1
	   fi
           until diff --brief ${myfile%.*}.aux ${myfile%.*}.aux.$$; do
	     cp ${myfile%.*}.aux ${myfile%.*}.aux.$$
	     pdfjadetex ${myfile%.*}.tex
	   done
	   rm ${myfile%.*}.aux.$$;;
  esac
done
exit 0
 |