xref: /netbsd-src/external/gpl2/texinfo/dist/util/texi2dvi (revision d3737e9cfd8cdb680cae0994d1d5f26b365d6d47)
129619d2aSchristos#! /bin/sh
229619d2aSchristos# texi2dvi --- produce DVI (or PDF) files from Texinfo (or LaTeX) sources.
329619d2aSchristos# Id: texi2dvi,v 1.34 2004/12/01 18:35:36 karl Exp
429619d2aSchristos#
529619d2aSchristos# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001,
629619d2aSchristos# 2002, 2003, 2004 Free Software Foundation, Inc.
729619d2aSchristos#
829619d2aSchristos# This program is free software; you can redistribute it and/or modify
929619d2aSchristos# it under the terms of the GNU General Public License as published by
1029619d2aSchristos# the Free Software Foundation; either version 2, or (at your option)
1129619d2aSchristos# any later version.
1229619d2aSchristos#
1329619d2aSchristos# This program is distributed in the hope that it will be useful,
1429619d2aSchristos# but WITHOUT ANY WARRANTY; without even the implied warranty of
1529619d2aSchristos# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1629619d2aSchristos# GNU General Public License for more details.
1729619d2aSchristos#
1829619d2aSchristos# You should have received a copy of the GNU General Public License
1929619d2aSchristos# along with this program; if not, you can either send email to this
2029619d2aSchristos# program's maintainer or write to: The Free Software Foundation,
2129619d2aSchristos# Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
2229619d2aSchristos#
2329619d2aSchristos# Original author: Noah Friedman.
2429619d2aSchristos#
2529619d2aSchristos# Please send bug reports, etc. to bug-texinfo@gnu.org.
2629619d2aSchristos# If possible, please send a copy of the output of the script called with
2729619d2aSchristos# the `--debug' option when making a bug report.
2829619d2aSchristos
2929619d2aSchristos# This string is expanded by rcs automatically when this file is checked out.
3029619d2aSchristosrcs_revision='Revision: 1.34 '
3129619d2aSchristosrcs_version=`set - $rcs_revision; echo $2`
3229619d2aSchristosprogram=`echo $0 | sed -e 's!.*/!!'`
3329619d2aSchristosversion="texi2dvi (GNU Texinfo 4.8) $rcs_version
3429619d2aSchristos
3529619d2aSchristosCopyright (C) 2004 Free Software Foundation, Inc.
3629619d2aSchristosThere is NO warranty.  You may redistribute this software
3729619d2aSchristosunder the terms of the GNU General Public License.
3829619d2aSchristosFor more information about these matters, see the files named COPYING."
3929619d2aSchristos
4029619d2aSchristosusage="Usage: $program [OPTION]... FILE...
4129619d2aSchristos
4229619d2aSchristosRun each Texinfo or LaTeX FILE through TeX in turn until all
4329619d2aSchristoscross-references are resolved, building all indices.  The directory
4429619d2aSchristoscontaining each FILE is searched for included files.  The suffix of FILE
4529619d2aSchristosis used to determine its language (LaTeX or Texinfo).
4629619d2aSchristos
4729619d2aSchristosMakeinfo is used to perform Texinfo macro expansion before running TeX
4829619d2aSchristoswhen needed.
4929619d2aSchristos
5029619d2aSchristosOperation modes:
5129619d2aSchristos  -b, --batch         no interaction
5229619d2aSchristos  -c, --clean         remove all auxiliary files
5329619d2aSchristos  -D, --debug         turn on shell debugging (set -x)
5429619d2aSchristos  -h, --help          display this help and exit successfully
5529619d2aSchristos  -o, --output=OFILE  leave output in OFILE (implies --clean);
5629619d2aSchristos                      Only one input FILE may be specified in this case
5729619d2aSchristos  -q, --quiet         no output unless errors (implies --batch)
5829619d2aSchristos  -s, --silent        same as --quiet
5929619d2aSchristos  -v, --version       display version information and exit successfully
6029619d2aSchristos  -V, --verbose       report on what is done
6129619d2aSchristos
6229619d2aSchristosTeX tuning:
6329619d2aSchristos  -@                   use @input instead of \input; for preloaded Texinfo
6429619d2aSchristos  -e, -E, --expand     force macro expansion using makeinfo
6529619d2aSchristos  -I DIR               search DIR for Texinfo files
6629619d2aSchristos  -l, --language=LANG  specify the LANG of FILE (LaTeX or Texinfo)
6729619d2aSchristos  -p, --pdf            use pdftex or pdflatex for processing
6829619d2aSchristos  -r, --recode         call recode before TeX to translate input characters
6929619d2aSchristos  -t, --command=CMD    insert CMD in copy of input file
7029619d2aSchristos   or --texinfo=CMD    multiple values accumulate
7129619d2aSchristos
7229619d2aSchristosThe values of the BIBTEX, LATEX (or PDFLATEX), MAKEINDEX, MAKEINFO,
7329619d2aSchristosTEX (or PDFTEX), TEXINDEX, and THUMBPDF environment variables are used
7429619d2aSchristosto run those commands, if they are set.  Any CMD strings are added
7529619d2aSchristosafter @setfilename for Texinfo input, in the first line for LaTeX input.
7629619d2aSchristos
7729619d2aSchristosEmail bug reports to <bug-texinfo@gnu.org>,
7829619d2aSchristosgeneral questions and discussion to <help-texinfo@gnu.org>.
7929619d2aSchristosTexinfo home page: http://www.gnu.org/software/texinfo/"
8029619d2aSchristos
8129619d2aSchristos# Initialize variables for option overriding and otherwise.
8229619d2aSchristos# Don't use `unset' since old bourne shells don't have this command.
8329619d2aSchristos# Instead, assign them an empty value.
8429619d2aSchristosbatch=false     # eval for batch mode
8529619d2aSchristosclean=
8629619d2aSchristosdebug=
8729619d2aSchristosescape='\'
8829619d2aSchristosexpand=         # t for expansion via makeinfo
8929619d2aSchristosmiincludes=     # makeinfo include path
9029619d2aSchristosoformat=dvi
9129619d2aSchristosoname=          # --output
9229619d2aSchristosquiet=          # by default let the tools' message be displayed
9329619d2aSchristosrecode=false
9429619d2aSchristosset_language=
9529619d2aSchristostextra=         # Extra TeX commands to insert in the input file.
9629619d2aSchristostextra_cmd=     # sed command to insert TEXTRA where appropriate
9729619d2aSchristostmpdir=${TMPDIR:-/tmp}/t2d$$  # avoid collisions on 8.3 filesystems.
9829619d2aSchristostxincludes=     # TEXINPUTS extensions, with trailing colon
9929619d2aSchristostxiprereq=19990129 # minimum texinfo.tex version with macro expansion
10029619d2aSchristosverbose=false   # echo for verbose mode
10129619d2aSchristos
10229619d2aSchristosorig_pwd=`pwd`
10329619d2aSchristos
10429619d2aSchristos# Systems which define $COMSPEC or $ComSpec use semicolons to separate
10529619d2aSchristos# directories in TEXINPUTS.
10629619d2aSchristosif test -n "$COMSPEC$ComSpec"; then
10729619d2aSchristos  path_sep=";"
10829619d2aSchristoselse
10929619d2aSchristos  path_sep=":"
11029619d2aSchristosfi
11129619d2aSchristos
11229619d2aSchristos# Pacify verbose cds.
11329619d2aSchristosCDPATH=${ZSH_VERSION+.}$path_sep
11429619d2aSchristos
11529619d2aSchristos# In case someone crazy insists on using grep -E.
11629619d2aSchristos: ${EGREP=egrep}
11729619d2aSchristos
11829619d2aSchristos# return true if program $1 is somewhere in PATH, else false.
11929619d2aSchristos#
12029619d2aSchristosfindprog () {
12129619d2aSchristos  foundprog=false
12229619d2aSchristos  for dir in `echo $PATH | tr "$path_sep" " "`; do
12329619d2aSchristos    if test -x "$dir/$1"; then  # does anyone still need test -f?
12429619d2aSchristos      foundprog=true
12529619d2aSchristos      break
12629619d2aSchristos    fi
12729619d2aSchristos  done
12829619d2aSchristos  $foundprog
12929619d2aSchristos}
13029619d2aSchristos
13129619d2aSchristos# Report an error and exit with failure.
13229619d2aSchristosfatal () {
13329619d2aSchristos  echo "$0: $*" >&2
13429619d2aSchristos  exit 1
13529619d2aSchristos}
13629619d2aSchristos
13729619d2aSchristos# Save TEXINPUTS so we can construct a new TEXINPUTS path for each file.
13829619d2aSchristos# Likewise for bibtex and makeindex.
13929619d2aSchristostex_envvars="BIBINPUTS BSTINPUTS INDEXSTYLE TEXINPUTS"
14029619d2aSchristosfor var in $tex_envvars; do
14129619d2aSchristos  eval ${var}_orig=\$$var
14229619d2aSchristos  export $var
14329619d2aSchristosdone
14429619d2aSchristos
14529619d2aSchristos
14629619d2aSchristos# Push a token among the arguments that will be used to notice when we
14729619d2aSchristos# ended options/arguments parsing.
14829619d2aSchristos# Use "set dummy ...; shift" rather than 'set - ..." because on
14929619d2aSchristos# Solaris set - turns off set -x (but keeps set -e).
15029619d2aSchristos# Use ${1+"$@"} rather than "$@" because Digital Unix and Ultrix 4.3
15129619d2aSchristos# still expand "$@" to a single argument (the empty string) rather
15229619d2aSchristos# than nothing at all.
15329619d2aSchristosarg_sep="$$--$$"
15429619d2aSchristosset dummy ${1+"$@"} "$arg_sep"; shift
15529619d2aSchristos
15629619d2aSchristos#
15729619d2aSchristos# Parse command line arguments.
15829619d2aSchristoswhile test x"$1" != x"$arg_sep"; do
15929619d2aSchristos
16029619d2aSchristos  # Handle --option=value by splitting apart and putting back on argv.
16129619d2aSchristos  case "$1" in
16229619d2aSchristos    --*=*)
16329619d2aSchristos      opt=`echo "$1" | sed -e 's/=.*//'`
16429619d2aSchristos      val=`echo "$1" | sed -e 's/[^=]*=//'`
16529619d2aSchristos      shift
16629619d2aSchristos      set dummy "$opt" "$val" ${1+"$@"}; shift
16729619d2aSchristos      ;;
16829619d2aSchristos  esac
16929619d2aSchristos
17029619d2aSchristos  # This recognizes --quark as --quiet.  So what.
17129619d2aSchristos  case "$1" in
17229619d2aSchristos    -@ ) escape=@;;
17329619d2aSchristos    # Silently and without documentation accept -b and --b[atch] as synonyms.
17429619d2aSchristos    -b | --b*) batch=true;;
17529619d2aSchristos    -c | --c*) clean=t;;
17629619d2aSchristos    -D | --d*) debug=t;;
17729619d2aSchristos    -e | -E | --e*) expand=t;;
17829619d2aSchristos    -h | --h*) echo "$usage"; exit 0;;
17929619d2aSchristos    -I | --I*)
18029619d2aSchristos      shift
18129619d2aSchristos      miincludes="$miincludes -I $1"
18229619d2aSchristos      txincludes="$txincludes$1$path_sep"
18329619d2aSchristos      ;;
18429619d2aSchristos    -l | --l*) shift; set_language=$1;;
18529619d2aSchristos    -o | --o*)
18629619d2aSchristos      shift
18729619d2aSchristos      clean=t
18829619d2aSchristos      case "$1" in
18929619d2aSchristos        /* | ?:/*) oname=$1;;
19029619d2aSchristos                *) oname="$orig_pwd/$1";;
19129619d2aSchristos      esac;;
19229619d2aSchristos    -p | --p*) oformat=pdf;;
19329619d2aSchristos    -q | -s | --q* | --s*) quiet=t; batch=true;;
19429619d2aSchristos    -r | --r*) recode=true;;
19529619d2aSchristos    -t | --tex* | --com* ) shift; textra="$textra\\
19629619d2aSchristos"`echo "$1" | sed 's/\\\\/\\\\\\\\/g'`;;
19729619d2aSchristos    -v | --vers*) echo "$version"; exit 0;;
19829619d2aSchristos    -V | --verb*) verbose=echo;;
19929619d2aSchristos    --) # What remains are not options.
20029619d2aSchristos      shift
20129619d2aSchristos      while test x"$1" != x"$arg_sep"; do
20229619d2aSchristos        set dummy ${1+"$@"} "$1"; shift
20329619d2aSchristos        shift
20429619d2aSchristos      done
20529619d2aSchristos      break;;
20629619d2aSchristos    -*)
20729619d2aSchristos      echo "$0: Unknown or ambiguous option \`$1'." >&2
20829619d2aSchristos      echo "$0: Try \`--help' for more information." >&2
20929619d2aSchristos      exit 1;;
21029619d2aSchristos    *) set dummy ${1+"$@"} "$1"; shift;;
21129619d2aSchristos   esac
21229619d2aSchristos   shift
21329619d2aSchristosdone
21429619d2aSchristos# Pop the token
21529619d2aSchristosshift
21629619d2aSchristos
21729619d2aSchristos# Interpret remaining command line args as filenames.
21829619d2aSchristoscase $# in
21929619d2aSchristos 0)
22029619d2aSchristos  echo "$0: Missing file arguments." >&2
22129619d2aSchristos  echo "$0: Try \`--help' for more information." >&2
22229619d2aSchristos  exit 2
22329619d2aSchristos  ;;
22429619d2aSchristos 1) ;;
22529619d2aSchristos *)
22629619d2aSchristos  if test -n "$oname"; then
22729619d2aSchristos    echo "$0: Can't use option \`--output' with more than one argument." >&2
22829619d2aSchristos    exit 2
22929619d2aSchristos  fi
23029619d2aSchristos  ;;
23129619d2aSchristosesac
23229619d2aSchristos
23329619d2aSchristos
23429619d2aSchristos# We can't do much without tex.
23529619d2aSchristos#
23629619d2aSchristosif findprog ${TEX:-tex}; then :; else cat <<EOM
23729619d2aSchristosYou don't have a working TeX binary (${TEX:-tex}) installed anywhere in
23829619d2aSchristosyour PATH, and texi2dvi cannot proceed without one.  If you want to use
23929619d2aSchristosthis script, you'll need to install TeX (if you don't have it) or change
24029619d2aSchristosyour PATH or TEX environment variable (if you do).  See the --help
24129619d2aSchristosoutput for more details.
24229619d2aSchristos
24329619d2aSchristosFor information about obtaining TeX, please see http://www.tug.org.  If
24429619d2aSchristosyou happen to be using Debian, you can get it with this command:
24529619d2aSchristos  apt-get install tetex-bin
24629619d2aSchristosEOM
24729619d2aSchristos  exit 1
24829619d2aSchristosfi
24929619d2aSchristos
25029619d2aSchristos
25129619d2aSchristos# We want to use etex (or pdftex) if they are available, and the user
25229619d2aSchristos# didn't explicitly specify.  We don't check for elatex and pdfelatex
25329619d2aSchristos# because (as of 2003), the LaTeX team has asked that new distributions
25429619d2aSchristos# use etex by default anyway.
25529619d2aSchristos#
25629619d2aSchristos# End up with the TEX and PDFTEX variables set to what we are going to use.
25729619d2aSchristosif test -z "$TEX"; then
25829619d2aSchristos  if findprog etex; then TEX=etex; else TEX=tex; fi
25929619d2aSchristosfi
26029619d2aSchristos#
26129619d2aSchristosif test -z "$PDFTEX"; then
26229619d2aSchristos  if findprog pdfetex; then PDFTEX=pdfetex; else PDFTEX=pdftex; fi
26329619d2aSchristosfi
26429619d2aSchristos
26529619d2aSchristos
26629619d2aSchristos# Prepare the temporary directory.  Remove it at exit, unless debugging.
26729619d2aSchristosif test -z "$debug"; then
26829619d2aSchristos  trap "cd / && rm -rf $tmpdir" 0 1 2 15
26929619d2aSchristosfi
27029619d2aSchristos
27129619d2aSchristos# Create the temporary directory with strict rights
27229619d2aSchristos(umask 077 && mkdir $tmpdir) || exit 1
27329619d2aSchristos
27429619d2aSchristos# Prepare the tools we might need.  This may be extra work in some
27529619d2aSchristos# cases, but improves the readability of the script.
27629619d2aSchristosutildir=$tmpdir/utils
27729619d2aSchristosmkdir $utildir || exit 1
27829619d2aSchristos
27929619d2aSchristos# A sed script that preprocesses Texinfo sources in order to keep the
28029619d2aSchristos# iftex sections only.  We want to remove non TeX sections, and comment
28129619d2aSchristos# (with `@c texi2dvi') TeX sections so that makeinfo does not try to
28229619d2aSchristos# parse them.  Nevertheless, while commenting TeX sections, don't
28329619d2aSchristos# comment @macro/@end macro so that makeinfo does propagate them.
28429619d2aSchristos# Unfortunately makeinfo --iftex --no-ifinfo doesn't work well enough
28529619d2aSchristos# (yet), makeinfo can't parse the TeX commands, so work around with sed.
28629619d2aSchristos#
28729619d2aSchristoscomment_iftex_sed=$utildir/comment.sed
28829619d2aSchristoscat <<EOF >$comment_iftex_sed
28929619d2aSchristos/^@tex/,/^@end tex/{
29029619d2aSchristos  s/^/@c texi2dvi/
29129619d2aSchristos}
29229619d2aSchristos/^@iftex/,/^@end iftex/{
29329619d2aSchristos  s/^/@c texi2dvi/
29429619d2aSchristos  /^@c texi2dvi@macro/,/^@c texi2dvi@end macro/{
29529619d2aSchristos    s/^@c texi2dvi//
29629619d2aSchristos  }
29729619d2aSchristos}
29829619d2aSchristos/^@ifnottex/,/^@end ifnottex/{
29929619d2aSchristos  s/^/@c (texi2dvi)/
30029619d2aSchristos}
30129619d2aSchristos/^@ifinfo/,/^@end ifinfo/{
30229619d2aSchristos  /^@node/p
30329619d2aSchristos  /^@menu/,/^@end menu/p
30429619d2aSchristos  t
30529619d2aSchristos  s/^/@c (texi2dvi)/
30629619d2aSchristos}
30729619d2aSchristoss/^@ifnotinfo/@c texi2dvi@ifnotinfo/
30829619d2aSchristoss/^@end ifnotinfo/@c texi2dvi@end ifnotinfo/
30929619d2aSchristosEOF
31029619d2aSchristos# Uncommenting is simple: Remove any leading `@c texi2dvi'.
31129619d2aSchristosuncomment_iftex_sed=$utildir/uncomment.sed
31229619d2aSchristoscat <<EOF >$uncomment_iftex_sed
31329619d2aSchristoss/^@c texi2dvi//
31429619d2aSchristosEOF
31529619d2aSchristos
31629619d2aSchristos# Compute the list of xref files.
31729619d2aSchristos# Takes the filename (without extension) of which we look for xref
31829619d2aSchristos# files as argument.  The index files must be reported last.
31929619d2aSchristosget_xref_files ()
32029619d2aSchristos{
32129619d2aSchristos  # Get list of xref files (indexes, tables and lists).
32229619d2aSchristos  # Find all files having root filename with a two-letter extension,
32329619d2aSchristos  # saves the ones that are really Texinfo-related files.  .?o? catches
32429619d2aSchristos  # many files: .toc, .log, LaTeX tables and lists, FiXme's .lox, maybe more.
32529619d2aSchristos  for this_file in "$1".?o? "$1".aux "$1".?? "$1".idx; do
32629619d2aSchristos    # If file is empty, skip it.
32729619d2aSchristos    test -s "$this_file" || continue
32829619d2aSchristos    # If the file is not suitable to be an index or xref file, don't
32929619d2aSchristos    # process it.  It's suitable if the first character is a
33029619d2aSchristos    # backslash or right quote or at, as long as the first line isn't
33129619d2aSchristos    # \input texinfo.
33229619d2aSchristos    first_character=`sed -n '1s/^\(.\).*$/\1/p;q' $this_file`
33329619d2aSchristos    if (test "x$first_character" = "x\\" \
33429619d2aSchristos        && sed 1q $this_file | grep -v '^\\input *texinfo' >/dev/null) \
33529619d2aSchristos       || test "x$first_character" = "x'" \
33629619d2aSchristos       || test "x$first_character" = "x@"; then
33729619d2aSchristos      xref_files="$xref_files ./$this_file"
33829619d2aSchristos    fi
33929619d2aSchristos  done
34029619d2aSchristos  echo "$xref_files"
34129619d2aSchristos}
34229619d2aSchristos
34329619d2aSchristos# File descriptor usage:
34429619d2aSchristos# 0 standard input
34529619d2aSchristos# 1 standard output (--verbose messages)
34629619d2aSchristos# 2 standard error
34729619d2aSchristos# 3 some systems may open it to /dev/tty
34829619d2aSchristos# 4 used on the Kubota Titan
34929619d2aSchristos# 5 tools output (turned off by --quiet)
35029619d2aSchristos
35129619d2aSchristos# Tools' output.  If quiet, discard, else redirect to the message flow.
35229619d2aSchristosif test "$quiet" = t; then
35329619d2aSchristos  exec 5>/dev/null
35429619d2aSchristoselse
35529619d2aSchristos  exec 5>&1
35629619d2aSchristosfi
35729619d2aSchristos
35829619d2aSchristos# Enable tracing
35929619d2aSchristosif test "$debug" = t; then
36029619d2aSchristos  exec 6>&1
36129619d2aSchristos  set -x
36229619d2aSchristoselse
36329619d2aSchristos  exec 6>/dev/null
36429619d2aSchristosfi
36529619d2aSchristos
36629619d2aSchristos#
36729619d2aSchristos# TeXify files.
36829619d2aSchristos
36929619d2aSchristosfor command_line_filename in ${1+"$@"}; do
37029619d2aSchristos  $verbose "Processing $command_line_filename ..."
37129619d2aSchristos
37229619d2aSchristos  # If the COMMAND_LINE_FILENAME is not absolute (e.g., --debug.tex),
37329619d2aSchristos  # prepend `./' in order to avoid that the tools take it as an option.
37429619d2aSchristos  echo "$command_line_filename" | $EGREP '^(/|[A-z]:/)' >&6 \
37529619d2aSchristos  || command_line_filename="./$command_line_filename"
37629619d2aSchristos
37729619d2aSchristos  # See if the file exists.  If it doesn't we're in trouble since, even
37829619d2aSchristos  # though the user may be able to reenter a valid filename at the tex
37929619d2aSchristos  # prompt (assuming they're attending the terminal), this script won't
38029619d2aSchristos  # be able to find the right xref files and so forth.
38129619d2aSchristos  if test ! -r "$command_line_filename"; then
38229619d2aSchristos    echo "$0: Could not read $command_line_filename, skipping." >&2
38329619d2aSchristos    continue
38429619d2aSchristos  fi
38529619d2aSchristos
38629619d2aSchristos  # Get the name of the current directory.  We want the full path
38729619d2aSchristos  # because in clean mode we are in tmp, in which case a relative
38829619d2aSchristos  # path has no meaning.
38929619d2aSchristos  filename_dir=`echo $command_line_filename | sed 's!/[^/]*$!!;s!^$!.!'`
39029619d2aSchristos  filename_dir=`cd "$filename_dir" >/dev/null && pwd`
39129619d2aSchristos
39229619d2aSchristos  # Strip directory part but leave extension.
39329619d2aSchristos  filename_ext=`basename "$command_line_filename"`
39429619d2aSchristos  # Strip extension.
39529619d2aSchristos  filename_noext=`echo "$filename_ext" | sed 's/\.[^.]*$//'`
39629619d2aSchristos  ext=`echo "$filename_ext" | sed 's/^.*\.//'`
39729619d2aSchristos
39829619d2aSchristos  # _src.  Use same basename since we want to generate aux files with
39929619d2aSchristos  # the same basename as the manual.  If --expand, then output the
40029619d2aSchristos  # macro-expanded file to here, else copy the original file.
40129619d2aSchristos  tmpdir_src=$tmpdir/src
40229619d2aSchristos  filename_src=$tmpdir_src/$filename_noext.$ext
40329619d2aSchristos
40429619d2aSchristos  # _xtr.  The file with the user's extra commands.
40529619d2aSchristos  tmpdir_xtr=$tmpdir/xtr
40629619d2aSchristos  filename_xtr=$tmpdir_xtr/$filename_noext.$ext
40729619d2aSchristos
40829619d2aSchristos  # _rcd.  The Texinfo file recoded in 7bit.
40929619d2aSchristos  tmpdir_rcd=$tmpdir/rcd
41029619d2aSchristos  filename_rcd=$tmpdir_rcd/$filename_noext.$ext
41129619d2aSchristos
41229619d2aSchristos  # _bak.  Copies of the previous xref files (another round is run if
41329619d2aSchristos  # they differ from the new one).
41429619d2aSchristos  tmpdir_bak=$tmpdir/bak
41529619d2aSchristos
41629619d2aSchristos  # Make all those directories and give up if we can't succeed.
41729619d2aSchristos  mkdir $tmpdir_src $tmpdir_xtr $tmpdir_rcd $tmpdir_bak || exit 1
41829619d2aSchristos
41929619d2aSchristos  # Source file might include additional sources.
42029619d2aSchristos  # We want `.:$orig_pwd' before anything else.  (We'll add `.:' later
42129619d2aSchristos  # after all other directories have been turned into absolute paths.)
42229619d2aSchristos  # `.' goes first to ensure that any old .aux, .cps,
42329619d2aSchristos  # etc. files in ${directory} don't get used in preference to fresher
42429619d2aSchristos  # files in `.'.  Include orig_pwd in case we are in clean mode, where
42529619d2aSchristos  # we've cd'd to a temp directory.
42629619d2aSchristos  common="$orig_pwd$path_sep$filename_dir$path_sep$txincludes"
42729619d2aSchristos  for var in $tex_envvars; do
42829619d2aSchristos    eval ${var}="\$common\$${var}_orig"
42929619d2aSchristos    export $var
43029619d2aSchristos  done
43129619d2aSchristos
43229619d2aSchristos  # Convert relative paths to absolute paths, so we can run in another
43329619d2aSchristos  # directory (e.g., in --clean mode, or during the macro-support detection.)
43429619d2aSchristos  #
43529619d2aSchristos  # Empty path components are meaningful to tex.  We rewrite them
43629619d2aSchristos  # as `EMPTY' so they don't get lost when we split on $path_sep.
43729619d2aSchristos  # Hopefully no one will have an actual directory named EMPTY.
43829619d2aSchristos  replace_empty="-e 's/^$path_sep/EMPTY$path_sep/g' \
43929619d2aSchristos                 -e 's/$path_sep\$/${path_sep}EMPTY/g' \
44029619d2aSchristos                 -e 's/$path_sep$path_sep/${path_sep}EMPTY:/g'"
44129619d2aSchristos   TEXINPUTS=`echo $TEXINPUTS  | eval sed $replace_empty`
44229619d2aSchristos  INDEXSTYLE=`echo $INDEXSTYLE | eval sed $replace_empty`
44329619d2aSchristos  save_IFS=$IFS
44429619d2aSchristos  IFS=$path_sep
44529619d2aSchristos  set x $TEXINPUTS; shift
44629619d2aSchristos  TEXINPUTS=.
44729619d2aSchristos  for dir
44829619d2aSchristos  do
44929619d2aSchristos    case $dir in
45029619d2aSchristos      EMPTY)
45129619d2aSchristos        TEXINPUTS=$TEXINPUTS$path_sep
45229619d2aSchristos        ;;
45329619d2aSchristos      [\\/]* | ?:[\\/]*)        # Absolute paths don't need to be expanded.
45429619d2aSchristos        TEXINPUTS=$TEXINPUTS$path_sep$dir
45529619d2aSchristos        ;;
45629619d2aSchristos      *)
45729619d2aSchristos        abs=`cd "$dir" && pwd` && TEXINPUTS=$TEXINPUTS$path_sep$abs
45829619d2aSchristos        ;;
45929619d2aSchristos    esac
46029619d2aSchristos  done
46129619d2aSchristos  set x $INDEXSTYLE; shift
46229619d2aSchristos  INDEXSTYLE=.
46329619d2aSchristos  for dir
46429619d2aSchristos  do
46529619d2aSchristos    case $dir in
46629619d2aSchristos      EMPTY)
46729619d2aSchristos        INDEXSTYLE=$INDEXSTYLE$path_sep
46829619d2aSchristos        ;;
46929619d2aSchristos      [\\/]* | ?:[\\/]*)        # Absolute paths don't need to be expansed.
47029619d2aSchristos        INDEXSTYLE=$INDEXSTYLE$path_sep$dir
47129619d2aSchristos        ;;
47229619d2aSchristos      *)
47329619d2aSchristos        abs=`cd "$dir" && pwd` && INDEXSTYLE=$INDEXSTYLE$path_sep$abs
47429619d2aSchristos        ;;
47529619d2aSchristos    esac
47629619d2aSchristos  done
47729619d2aSchristos  IFS=$save_IFS
47829619d2aSchristos
47929619d2aSchristos  # If the user explicitly specified the language, use that.
48029619d2aSchristos  # Otherwise, if the first line is \input texinfo, assume it's texinfo.
48129619d2aSchristos  # Otherwise, guess from the file extension.
48229619d2aSchristos  if test -n "$set_language"; then
48329619d2aSchristos    language=$set_language
48429619d2aSchristos  elif sed 1q "$command_line_filename" | grep 'input texinfo' >&6; then
48529619d2aSchristos    language=texinfo
48629619d2aSchristos  else
48729619d2aSchristos    language=
48829619d2aSchristos  fi
48929619d2aSchristos
49029619d2aSchristos  # Get the type of the file (latex or texinfo) from the given language
49129619d2aSchristos  # we just guessed, or from the file extension if not set yet.
49229619d2aSchristos  case ${language:-$filename_ext} in
49329619d2aSchristos    [lL]a[tT]e[xX] | *.ltx | *.tex)
49429619d2aSchristos      # Assume a LaTeX file.  LaTeX needs bibtex and uses latex for
49529619d2aSchristos      # compilation.  No makeinfo.
49629619d2aSchristos      language=latex
49729619d2aSchristos      bibtex=${BIBTEX:-bibtex}
49829619d2aSchristos      makeinfo= # no point in running makeinfo on latex source.
49929619d2aSchristos      texindex=${MAKEINDEX:-makeindex}
50029619d2aSchristos      textra_cmd=1i
50129619d2aSchristos      if test $oformat = dvi; then
50229619d2aSchristos        tex=${LATEX:-latex}
50329619d2aSchristos      else
50429619d2aSchristos        tex=${PDFLATEX:-pdflatex}
50529619d2aSchristos      fi
50629619d2aSchristos      thumbpdf=${THUMBPDF:-thumbpdf}
50729619d2aSchristos      ;;
50829619d2aSchristos
50929619d2aSchristos    *)
51029619d2aSchristos      # Assume a Texinfo file.  Texinfo files need makeinfo, texindex and tex.
51129619d2aSchristos      language=texinfo
51229619d2aSchristos      bibtex=
51329619d2aSchristos      texindex=${TEXINDEX:-texindex}
51429619d2aSchristos      textra_cmd='/^@setfilename/a'
51529619d2aSchristos      if test $oformat = dvi; then
51629619d2aSchristos        # MetaPost also uses the TEX environment variable.  If the user
51729619d2aSchristos        # has set TEX=latex for that reason, don't bomb out.
51829619d2aSchristos        if echo $TEX | grep 'latex$' >/dev/null; then
51929619d2aSchristos          tex=tex  # don't bother trying to find etex
52029619d2aSchristos        else
52129619d2aSchristos          tex=$TEX
52229619d2aSchristos        fi
52329619d2aSchristos      else
52429619d2aSchristos        tex=$PDFTEX
52529619d2aSchristos      fi
52629619d2aSchristos      # Unless required by the user, makeinfo expansion is wanted only
52729619d2aSchristos      # if texinfo.tex is too old.
52829619d2aSchristos      if test "$expand" = t; then
52929619d2aSchristos        makeinfo=${MAKEINFO:-makeinfo}
53029619d2aSchristos      else
53129619d2aSchristos        # Check if texinfo.tex performs macro expansion by looking for
53229619d2aSchristos        # its version.  The version is a date of the form YEAR-MO-DA.
53329619d2aSchristos        # We don't need to use [0-9] to match the digits since anyway
53429619d2aSchristos        # the comparison with $txiprereq, a number, will fail with non
53529619d2aSchristos        # digits.
53629619d2aSchristos        # Run in the tmpdir to avoid leaving files.
53729619d2aSchristos	(
53829619d2aSchristos           cd $tmpdir
53929619d2aSchristos	   echo '\input texinfo.tex @bye' >txiversion.tex
54029619d2aSchristos	   # Be sure that if tex wants to fail, it is not interactive:
54129619d2aSchristos	   # close stdin.
54229619d2aSchristos           $tex txiversion.tex </dev/null
54329619d2aSchristos	) >$tmpdir/txiversion.out 2>$tmpdir/txiversion.err
54429619d2aSchristos	if test $? != 0; then
54529619d2aSchristos	  cat $tmpdir/txiversion.out
54629619d2aSchristos	  cat $tmpdir/txiversion.err >&2
54729619d2aSchristos	  fatal "texinfo.tex appears to be broken, quitting."
54829619d2aSchristos        fi
54929619d2aSchristos	eval `sed -n 's/^.*\[\(.*\)version \(....\)-\(..\)-\(..\).*$/txiformat=\1 txiversion="\2\3\4"/p' $tmpdir/txiversion.out`
55029619d2aSchristos        $verbose "texinfo.tex preloaded as \`$txiformat', version is \`$txiversion' ..."
55129619d2aSchristos        if test "$txiprereq" -le "$txiversion" >/dev/null 2>&1; then
55229619d2aSchristos          makeinfo=
55329619d2aSchristos        else
55429619d2aSchristos          makeinfo=${MAKEINFO:-makeinfo}
55529619d2aSchristos        fi
55629619d2aSchristos        # As long as we had to run TeX, offer the user this convenience:
55729619d2aSchristos        test "$txiformat" = Texinfo && escape=@
55829619d2aSchristos      fi
55929619d2aSchristos      thumbpdf=${THUMBPDF:-thumbpdf}
56029619d2aSchristos      ;;
56129619d2aSchristos  esac
56229619d2aSchristos
56329619d2aSchristos  # Go to $tmpdir to try --help, since old versions that don't accept
56429619d2aSchristos  # --help will generate a texput.log.
56529619d2aSchristos  tex_help=`cd $tmpdir >/dev/null && $tex --help </dev/null 2>&1`
56629619d2aSchristos
56729619d2aSchristos  # If possible, make TeX report error locations in GNU format.
56829619d2aSchristos  tex_args=
56929619d2aSchristos  case $tex_help in
57029619d2aSchristos    *file-line-error*) tex_args="$tex_args --file-line-error";;
57129619d2aSchristos  esac
57229619d2aSchristos
57329619d2aSchristos  # Tell TeX to be batch if requested.  (\batchmode does not show
57429619d2aSchristos  # terminal output at all, so we don't want that.)
57529619d2aSchristos  $batch && tex_args="$tex_args ${escape}nonstopmode ${escape}input"
57629619d2aSchristos
57729619d2aSchristos  # Expand macro commands in the original source file using Makeinfo.
57829619d2aSchristos  # Always use `end' footnote style, since the `separate' style
57929619d2aSchristos  #   generates different output (arguably this is a bug in -E).
58029619d2aSchristos  # Discard main info output, the user asked to run TeX, not makeinfo.
58129619d2aSchristos  if test -n "$makeinfo"; then
58229619d2aSchristos    $verbose "Macro-expanding $command_line_filename to $filename_src ..."
58329619d2aSchristos    sed -f $comment_iftex_sed "$command_line_filename" \
58429619d2aSchristos      | $makeinfo --footnote-style=end -I "$filename_dir" $miincludes \
58529619d2aSchristos        -o /dev/null --macro-expand=- \
58629619d2aSchristos      | sed -f $uncomment_iftex_sed >"$filename_src"
58729619d2aSchristos    filename_input=$filename_src
58829619d2aSchristos  fi
58929619d2aSchristos
59029619d2aSchristos  # If makeinfo failed (or was not even run), use the original file as input.
59129619d2aSchristos  if test $? -ne 0 \
59229619d2aSchristos     || test ! -r "$filename_src"; then
59329619d2aSchristos    $verbose "Reverting to $command_line_filename ..."
59429619d2aSchristos    filename_input=$filename_dir/$filename_ext
59529619d2aSchristos  fi
59629619d2aSchristos
59729619d2aSchristos  # Used most commonly for @finalout, @smallbook, etc.
59829619d2aSchristos  if test -n "$textra"; then
59929619d2aSchristos    $verbose "Inserting extra commands: $textra"
60029619d2aSchristos    sed "$textra_cmd\\
60129619d2aSchristos$textra" "$filename_input" >"$filename_xtr"
60229619d2aSchristos    filename_input=$filename_xtr
60329619d2aSchristos  fi
60429619d2aSchristos
60529619d2aSchristos  # If this is a Texinfo file with a specified input encoding, and
60629619d2aSchristos  # recode is available, then recode to plain 7 bit Texinfo.
60729619d2aSchristos  if test $language = texinfo; then
60829619d2aSchristos    pgm='s/\(^\|.* \)@documentencoding  *\([^ ][^ ]*\)\( .*\|$\)/\2/
60929619d2aSchristos	t found
61029619d2aSchristos	d
61129619d2aSchristos	:found
61229619d2aSchristos	q'
61329619d2aSchristos    encoding=`sed -e "$pgm" "$filename_input"`
61429619d2aSchristos    if $recode && test -n "$encoding" && findprog recode; then
61529619d2aSchristos      $verbose "Recoding from $encoding to Texinfo."
61629619d2aSchristos      if recode "$encoding"..texinfo <"$filename_input" >"$filename_rcd" \
61729619d2aSchristos         && test -s "$filename_rcd"; then
61829619d2aSchristos        filename_input=$filename_rcd
61929619d2aSchristos      else
62029619d2aSchristos        $verbose "Recoding failed, using original input."
62129619d2aSchristos      fi
62229619d2aSchristos    fi
62329619d2aSchristos  fi
62429619d2aSchristos
62529619d2aSchristos  # If clean mode was specified, then move to the temporary directory.
62629619d2aSchristos  if test "$clean" = t; then
62729619d2aSchristos    $verbose "cd $tmpdir_src"
62829619d2aSchristos    cd "$tmpdir_src" || exit 1
62929619d2aSchristos  fi
63029619d2aSchristos
63129619d2aSchristos  while :; do # will break out of loop below
63229619d2aSchristos    orig_xref_files=`get_xref_files "$filename_noext"`
63329619d2aSchristos
63429619d2aSchristos    # Save copies of originals for later comparison.
63529619d2aSchristos    if test -n "$orig_xref_files"; then
63629619d2aSchristos      $verbose "Backing up xref files: `echo $orig_xref_files | sed 's|\./||g'`"
63729619d2aSchristos      cp $orig_xref_files $tmpdir_bak
63829619d2aSchristos    fi
63929619d2aSchristos
64029619d2aSchristos    # Run bibtex on current file.
64129619d2aSchristos    # - If its input (AUX) exists.
64229619d2aSchristos    # - If AUX contains both `\bibdata' and `\bibstyle'.
64329619d2aSchristos    # - If some citations are missing (LOG contains `Citation').
64429619d2aSchristos    #   or the LOG complains of a missing .bbl
64529619d2aSchristos    #
64629619d2aSchristos    # We run bibtex first, because I can see reasons for the indexes
64729619d2aSchristos    # to change after bibtex is run, but I see no reason for the
64829619d2aSchristos    # converse.
64929619d2aSchristos    #
65029619d2aSchristos    # Don't try to be too smart.  Running bibtex only if the bbl file
65129619d2aSchristos    # exists and is older than the LaTeX file is wrong, since the
65229619d2aSchristos    # document might include files that have changed.  Because there
65329619d2aSchristos    # can be several AUX (if there are \include's), but a single LOG,
65429619d2aSchristos    # looking for missing citations in LOG is easier, though we take
65529619d2aSchristos    # the risk to match false messages.
65629619d2aSchristos    if test -n "$bibtex" \
65729619d2aSchristos       && test -r "$filename_noext.aux" \
65829619d2aSchristos       && test -r "$filename_noext.log" \
65929619d2aSchristos       && (grep '^\\bibdata[{]'  "$filename_noext.aux" \
66029619d2aSchristos           && grep '^\\bibstyle[{]' "$filename_noext.aux" \
66129619d2aSchristos           && (grep 'Warning:.*Citation.*undefined' "$filename_noext.log" \
66229619d2aSchristos               || grep 'No file .*\.bbl\.' "$filename_noext.log")) \
66329619d2aSchristos          >&6 2>&1; \
66429619d2aSchristos    then
66529619d2aSchristos      $verbose "Running $bibtex $filename_noext ..."
66629619d2aSchristos      $bibtex "$filename_noext" >&5 ||
66729619d2aSchristos        fatal "$bibtex exited with bad status, quitting."
66829619d2aSchristos    fi
66929619d2aSchristos
67029619d2aSchristos    # What we'll run texindex on -- exclude non-index files.
67129619d2aSchristos    # Since we know index files are last, it is correct to remove everything
67229619d2aSchristos    # before .aux and .?o?.  But don't really do <anything>o<anything>
67329619d2aSchristos    # -- don't match whitespace as <anything>.
67429619d2aSchristos    # Otherwise, if orig_xref_files contains something like
67529619d2aSchristos    #   foo.xo foo.whatever
67629619d2aSchristos    # the space after the o will get matched.
67729619d2aSchristos    index_files=`echo "$orig_xref_files" \
67829619d2aSchristos                 | sed "s!.*\.aux!!g;
67929619d2aSchristos                        s!./$filename_noext\.[^ ]o[^ ]!!g;
68029619d2aSchristos                        s/^[ ]*//;s/[ ]*$//"`
68129619d2aSchristos    # Run texindex (or makeindex) on current index files.  If they
68229619d2aSchristos    # already exist, and after running TeX a first time the index
68329619d2aSchristos    # files don't change, then there's no reason to run TeX again.
68429619d2aSchristos    # But we won't know that if the index files are out of date or
68529619d2aSchristos    # nonexistent.
68629619d2aSchristos    if test -n "$texindex" && test -n "$index_files"; then
68729619d2aSchristos      $verbose "Running $texindex $index_files ..."
68829619d2aSchristos      $texindex $index_files 2>&5 1>&2 ||
68929619d2aSchristos         fatal "$texindex exited with bad status, quitting."
69029619d2aSchristos    fi
69129619d2aSchristos
69229619d2aSchristos    # Finally, run TeX.
69329619d2aSchristos    cmd="$tex $tex_args"
694*d3737e9cSchristos    $verbose "Running $cmd ..."
69529619d2aSchristos    if $cmd "$filename_input" >&5; then :; else
696*d3737e9cSchristos      echo "$0: TeX failed. If the above said 'tex: not found', " >&2
697*d3737e9cSchristos      echo "$0: you may need to install TeX;" >&2
698*d3737e9cSchristos      echo "$0: it is available from the pkgsrc system in print/teTeX." >&2
699*d3737e9cSchristos      echo "$0: If TeX is installed, make sure it is in your $PATH, or" >&2
700*d3737e9cSchristos      echo "$0: set the environment variable $TEX to its location." >&2
70129619d2aSchristos      echo "$0: $tex exited with bad status, quitting." >&2
70229619d2aSchristos      echo "$0: see $filename_noext.log for errors." >&2
70329619d2aSchristos      test "$clean" = t \
70429619d2aSchristos        && cp "$filename_noext.log" "$orig_pwd"
70529619d2aSchristos      exit 1
70629619d2aSchristos    fi
70729619d2aSchristos
70829619d2aSchristos
70929619d2aSchristos    # Decide if looping again is needed.
71029619d2aSchristos    finished=t
71129619d2aSchristos
71229619d2aSchristos    # LaTeX (and the package changebar) report in the LOG file if it
71329619d2aSchristos    # should be rerun.  This is needed for files included from
71429619d2aSchristos    # subdirs, since texi2dvi does not try to compare xref files in
71529619d2aSchristos    # subdirs.  Performing xref files test is still good since LaTeX
71629619d2aSchristos    # does not report changes in xref files.
71729619d2aSchristos    if grep "Rerun to get" "$filename_noext.log" >&6 2>&1; then
71829619d2aSchristos      finished=
71929619d2aSchristos    fi
72029619d2aSchristos
72129619d2aSchristos    # Check if xref files changed.
72229619d2aSchristos    new_xref_files=`get_xref_files "$filename_noext"`
72329619d2aSchristos    $verbose "Original xref files = `echo $orig_xref_files | sed 's|\./||g'`"
72429619d2aSchristos    $verbose "New xref files      = `echo $new_xref_files | sed 's|\./||g'`"
72529619d2aSchristos
72629619d2aSchristos    # If old and new lists don't at least have the same file list,
72729619d2aSchristos    # then one file or another has definitely changed.
72829619d2aSchristos    test "x$orig_xref_files" != "x$new_xref_files" && finished=
72929619d2aSchristos
73029619d2aSchristos    # File list is the same.  We must compare each file until we find
73129619d2aSchristos    # a difference.
73229619d2aSchristos    if test -n "$finished"; then
73329619d2aSchristos      for this_file in $new_xref_files; do
73429619d2aSchristos        $verbose "Comparing xref file `echo $this_file | sed 's|\./||g'` ..."
73529619d2aSchristos        # cmp -s returns nonzero exit status if files differ.
73629619d2aSchristos        if cmp -s "$this_file" "$tmpdir_bak/$this_file"; then :; else
73729619d2aSchristos          # We only need to keep comparing until we find one that
73829619d2aSchristos          # differs, because we'll have to run texindex & tex again no
73929619d2aSchristos          # matter how many more there might be.
74029619d2aSchristos          finished=
74129619d2aSchristos          $verbose "xref file `echo $this_file | sed 's|\./||g'` differed ..."
74229619d2aSchristos          test "$debug" = t && diff -c "$tmpdir_bak/$this_file" "$this_file"
74329619d2aSchristos          break
74429619d2aSchristos        fi
74529619d2aSchristos      done
74629619d2aSchristos    fi
74729619d2aSchristos
74829619d2aSchristos    # If finished, exit the loop, else rerun the loop.
74929619d2aSchristos    test -n "$finished" && break
75029619d2aSchristos  done # while :;
75129619d2aSchristos
75229619d2aSchristos  # If we were using thumbpdf and producing PDF, then run thumbpdf
75329619d2aSchristos  # and TeX one last time.
75429619d2aSchristos  if test $oformat = pdf \
75529619d2aSchristos     && test -r "$filename_noext.log" \
75629619d2aSchristos     && grep 'thumbpdf\.sty'  "$filename_noext.log" >&6 2>&1; \
75729619d2aSchristos  then
75829619d2aSchristos    $verbose "Running $thumbpdf $filename_noext ..."
75929619d2aSchristos    $thumbpdf "$filename_noext" >&5 ||
76029619d2aSchristos      fatal "$thumbpdf exited with bad status, quitting."
76129619d2aSchristos
76229619d2aSchristos    $verbose "Running $cmd $filename_input..."
76329619d2aSchristos    if $cmd "$filename_input" >&5; then :; else
76429619d2aSchristos      echo "$0: $tex exited with bad status, quitting." >&2
76529619d2aSchristos      echo "$0: see $filename_noext.log for errors." >&2
76629619d2aSchristos      test "$clean" = t \
76729619d2aSchristos	&& cp "$filename_noext.log" "$orig_pwd"
76829619d2aSchristos      exit 1
76929619d2aSchristos    fi
77029619d2aSchristos  fi
77129619d2aSchristos
77229619d2aSchristos
77329619d2aSchristos  # If we were in clean mode, compilation was in a tmp directory.
77429619d2aSchristos  # Copy the DVI (or PDF) file into the directory where the compilation
77529619d2aSchristos  # has been done.  (The temp dir is about to get removed anyway.)
77629619d2aSchristos  # We also return to the original directory so that
77729619d2aSchristos  # - the next file is processed in correct conditions
77829619d2aSchristos  # - the temporary file can be removed
77929619d2aSchristos  if test -n "$clean"; then
78029619d2aSchristos    if test -n "$oname"; then
78129619d2aSchristos       dest=$oname
78229619d2aSchristos    else
78329619d2aSchristos       dest=$orig_pwd
78429619d2aSchristos    fi
78529619d2aSchristos    $verbose "Copying $oformat file from `pwd` to $dest"
78629619d2aSchristos    cp -p "./$filename_noext.$oformat" "$dest"
78729619d2aSchristos    cd / # in case $orig_pwd is on a different drive (for DOS)
78829619d2aSchristos    cd $orig_pwd || exit 1
78929619d2aSchristos  fi
79029619d2aSchristos
79129619d2aSchristos  # Remove temporary files.
79229619d2aSchristos  if test "x$debug" = "x"; then
79329619d2aSchristos    $verbose "Removing $tmpdir_src $tmpdir_xtr $tmpdir_bak ..."
79429619d2aSchristos    cd /
79529619d2aSchristos    rm -rf $tmpdir_src $tmpdir_xtr $tmpdir_bak
79629619d2aSchristos  fi
79729619d2aSchristosdone
79829619d2aSchristos
79929619d2aSchristos$verbose "$0: done."
80029619d2aSchristosexit 0 # exit successfully, not however we ended the loop.
801