annotate man/texi2dvi @ 24:4103f0995bd7 r19-15b95

Import from CVS: tag r19-15b95
author cvs
date Mon, 13 Aug 2007 08:51:03 +0200
parents 376386a54a3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 #! /bin/sh
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 # texi2dvi --- smartly produce DVI files from texinfo sources
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 # Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 # $Id: texi2dvi,v 1.1.1.1 1996/12/18 03:35:32 steve Exp $
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 # This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 # it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 # the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 # any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 #
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 # This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 # GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 #
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 # You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 # along with this program; if not, you can either send email to this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 # program's maintainer or write to: The Free Software Foundation,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 # Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 # Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 # Author: Noah Friedman <friedman@prep.ai.mit.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 # Please send bug reports, etc. to bug-texinfo@prep.ai.mit.edu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 # If possible, please send a copy of the output of the script called with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 # the `--debug' option when making a bug report.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 # In the interest of general portability, some common bourne shell
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 # constructs were avoided because they weren't guaranteed to be available
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 # in some earlier implementations. I've tried to make this program as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 # portable as possible. Welcome to unix, where the lowest common
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 # denominator is rapidly diminishing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 #
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 # Among the more interesting lossages I noticed with some bourne shells
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 # are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 # * No shell functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 # * No `unset' builtin.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 # * `shift' cannot take a numeric argument, and signals an error if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 # there are no arguments to shift.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 # Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 # Name by which this script was invoked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 progname=`echo "$0" | sed -e 's/[^\/]*\///g'`
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 # This string is expanded by rcs automatically when this file is checked out.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 rcs_revision='$Revision: 1.1.1.1 $'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 version=`set - $rcs_revision; echo $2`
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 # To prevent hairy quoting and escaping later.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 bq='`'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 eq="'"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 usage="Usage: $progname {options} [file1] {file2 {...}}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (version $version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 Options are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 -D, --debug Turn on shell debugging ($bq${bq}set -x$eq$eq).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 -h, --help You're looking at it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 -v, --version Print version number.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 Arguments in brackets are required. Those in braces are optional.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 # Initialize variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 # Don't use `unset' since old bourne shells don't have this command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 # Instead, assign them an empty value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 # Some of these, like TEX and TEXINDEX, may be inherited from the environment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 backup_extension=.bak
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 debug=
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 orig_pwd="`pwd`"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 verbose=
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 texindex="${TEXINDEX-texindex}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 tex="${TEX-tex}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 # Save this so we can construct a new TEXINPUTS path for each file to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 # processed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 TEXINPUTS_orig="$TEXINPUTS"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 export TEXINPUTS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 # Parse command line arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 # Make sure that all wildcarded options are long enough to be unambiguous.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 # It's a good idea to document the full long option name in each case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 # Long options which take arguments will need a `*' appended to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 # canonical name to match the value appended after the `=' character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 while : ; do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 case $# in 0) break ;; esac
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 case "$1" in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 -D | --debug | --d* )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 debug=t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 shift
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 -h | --help | --h* )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 echo "$usage" 1>&2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 exit 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 -v | --version | --v* )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 echo "texi2dvi version $version" 1>&2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 exit 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 -- ) # Stop option processing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 shift
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 -* )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 case "$1" in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 --*=* ) arg=`echo "$1" | sed -e 's/=.*//'` ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 * ) arg="$1" ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 esac
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 exec 1>&2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 echo "$progname: unknown or ambiguous option $bq$arg$eq"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 echo "$progname: Use $bq--help$eq for a list of options."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 exit 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 * )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 esac
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 # See if there are any command line args left (which will be interpreted as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 # filename arguments)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 case $# in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 0 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 exec 1>&2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 echo "$progname: at least one file name is required as an argument."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 echo "$progname: Use $bq--help$eq for a description of command syntax."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 exit 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 esac
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 case "$debug" in t ) set -x ;; esac
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 # Texify files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 for command_line_filename in ${1+"$@"} ; do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 # Roughly equivalent to `dirname ...`, but more portable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 directory="`echo ${command_line_filename} | sed 's/\/[^\/]*$//'`"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 filename_texi="`basename ${command_line_filename}`"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 # Strip off the last extension part (probably .texinfo or .texi)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 filename_noext="`echo ${filename_texi} | sed 's/\.[^.]*$//'`"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 # If directory and file are the same, then it's probably because there's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 # no pathname component. Set dirname to `.', the current directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 if test "z${directory}" = "z${command_line_filename}" ; then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 directory="."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 fi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 # Source file might @include additional texinfo sources. Put `.' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 # directory where source file(s) reside in TEXINPUTS before anything
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 # else. `.' goes first to ensure that any old .aux, .cps, etc. files in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 # ${directory} don't get used in preference to fresher files in `.'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 TEXINPUTS=".:${directory}:${TEXINPUTS_orig}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 # "Unset" variables that might have values from previous iterations and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 # which won't be completely reset later.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 definite_index_files=""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 # See if file exists here. If it doesn't we're in trouble since, even
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 # though the user may be able to reenter a valid filename at the tex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 # prompt (assuming they're attending the terminal), this script won't be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 # able to find the right index files and so forth.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 if test ! -r "${command_line_filename}" ; then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 echo "${progname}: ${command_line_filename}: No such file or permission denied." 1>&2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 fi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 # Find all files having root filename with a two-letter extension,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 # determine whether they're really index files, and save them. Foo.aux
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 # is actually the cross-references file, but we need to keep track of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 # that too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 possible_index_files="`eval echo ${filename_noext}.?? ${filename_noext}.aux`"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 for this_file in ${possible_index_files} ; do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 # If file is empty, forget it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 if test ! -s "${this_file}" ; then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 fi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 # Examine first character of file. If it's not a backslash or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 # single quote, then it's definitely not an index or xref file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 first_character="`sed -n '1s/^\(.\).*$/\1/p;q' ${this_file}`"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 if test "${first_character}" = "\\" -o "${first_character}" = "'" ; then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 definite_index_files="${definite_index_files} ${this_file}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 fi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 orig_index_files="${definite_index_files}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 orig_index_files_sans_aux="`echo ${definite_index_files} \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 | sed 's/'${filename_noext}'\.aux//;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 s/^[ ]*//;s/[ ]*$//;'`"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 # Now save copies of original index files so we have some means of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 # comparison later.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 for index_file_to_save in ${orig_index_files} ; do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 cp "${index_file_to_save}" "${index_file_to_save}${backup_extension}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 # Run texindex on current index files. If they already exist, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 # after running TeX a first time the index files don't change, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 # there's no reason to run TeX again. But we won't know that if the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 # index files are out of date or nonexistent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 if test "${orig_index_files_sans_aux}" ; then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ${texindex} ${orig_index_files_sans_aux}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 fi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 if ${tex} ${command_line_filename} ; then # TeX run first time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 definite_index_files=""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 # Get list of new index files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 possible_index_files="`eval echo ${filename_noext}.?? ${filename_noext}.aux`"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 for this_file in ${possible_index_files} ; do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 # If file is empty, forget it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 if test ! -s ${this_file} ; then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 fi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 # Examine first character of file. If it's not a backslash or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 # single quote, then it's definitely not an index or xref file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 first_character="`sed -n '1s/^\(.\).*$/\1/p;q' ${this_file}`"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 if test "${first_character}" = "\\" -o "${first_character}" = "'" ; then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 definite_index_files="${definite_index_files} ${this_file}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 fi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 new_index_files="${definite_index_files}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 new_index_files_sans_aux="`echo ${definite_index_files} \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 | sed 's/'${filename_noext}'\.aux//;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 s/^[ ]*//;s/[ ]*$//;'`"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 # If old and new list don't at least have the same file list, then one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 # file or another has definitely changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 if test "${orig_index_files}" != "${new_index_files}" ; then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 index_files_changed_p=t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 # File list is the same. We must compare each file until we find a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 # difference.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 index_files_changed_p=""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 for this_file in ${new_index_files} ; do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 # cmp -s will return nonzero exit status if files differ.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 cmp -s "${this_file}" "${this_file}${backup_extension}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 if test $? -ne 0 ; then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 # We only need to keep comparing until we find *one* that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 # differs, because we'll have to run texindex & tex no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 # matter what.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 index_files_changed_p=t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 break
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 fi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 fi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 # If index files have changed since TeX has been run, or if the aux
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 # file wasn't present originally, run texindex and TeX again.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 if test "${index_files_changed_p}" ; then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 retval=0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 if test "${new_index_files_sans_aux}" ; then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ${texindex} ${new_index_files_sans_aux}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 retval=$?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 fi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 if test ${retval} -eq 0 ; then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ${tex} "${command_line_filename}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 fi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 fi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 fi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 # Generate list of files to delete, then call rm once with the entire
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 # list. This is significantly faster than multiple executions of rm.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 file_list=""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 for file in ${orig_index_files} ; do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 file_list="${file_list} ${file}${backup_extension}"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 if test "${file_list}" ; then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 rm -f ${file_list}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 fi
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 done
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 # texi2dvi ends here