summaryrefslogtreecommitdiff
path: root/Master/bin/i386-linux
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2008-08-11 00:20:50 +0000
committerKarl Berry <karl@freefriends.org>2008-08-11 00:20:50 +0000
commit04a0f8bd71c3e3be198876450e01590bbc2bbeb1 (patch)
tree5bc4d12fefb1a94900af8038ff001d8d64062705 /Master/bin/i386-linux
parentf9ca55d045a25e9eb1b1d6f89d2827518262d476 (diff)
texi2dvi braces fix (among much else)
git-svn-id: svn://tug.org/texlive/trunk@10240 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/bin/i386-linux')
-rwxr-xr-xMaster/bin/i386-linux/texi2dvi389
1 files changed, 232 insertions, 157 deletions
diff --git a/Master/bin/i386-linux/texi2dvi b/Master/bin/i386-linux/texi2dvi
index 4607be1949e..877ea9599dd 100755
--- a/Master/bin/i386-linux/texi2dvi
+++ b/Master/bin/i386-linux/texi2dvi
@@ -1,6 +1,6 @@
#! /bin/sh
# texi2dvi --- produce DVI (or PDF) files from Texinfo (or (La)TeX) sources.
-# $Id: texi2dvi,v 1.122 2008/04/17 18:45:49 karl Exp $
+# $Id: texi2dvi,v 1.133 2008/08/11 00:18:29 karl Exp $
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001,
# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
@@ -33,112 +33,13 @@ unset RUNNING_KSH
set -e
# This string is expanded by rcs automatically when this file is checked out.
-rcs_revision='$Revision: 1.122 $'
+rcs_revision='$Revision: 1.133 $'
rcs_version=`set - $rcs_revision; echo $2`
program=`echo $0 | sed -e 's!.*/!!'`
-version="texi2dvi (GNU Texinfo 4.12) $rcs_version
-
-Copyright (C) 2008 Free Software Foundation, Inc.
-License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
-This is free software: you are free to change and redistribute it.
-There is NO WARRANTY, to the extent permitted by law.
-"
build_mode=${TEXI2DVI_BUILD_MODE:-local}
build_dir=${TEXI2DVI_BUILD_DIRECTORY:-.}
-usage="Usage: $program [OPTION]... FILE...
-
-Run each Texinfo or (La)TeX FILE through TeX in turn until all
-cross-references are resolved, building all indices. The directory
-containing each FILE is searched for included files. The suffix of FILE
-is used to determine its language ((La)TeX or Texinfo). To process
-(e)plain TeX files, set the environment variable LATEX=tex.
-
-In order to make texi2dvi a drop-in replacement of TeX/LaTeX in AUC-TeX,
-the FILE may also be composed of the following simple TeX commands.
- \`\\input{FILE}' the actual file to compile
- \`\\nonstopmode' same as --batch
-
-Makeinfo is used to perform Texinfo macro expansion before running TeX
-when needed.
-
-General options:
- -b, --batch no interaction
- -D, --debug turn on shell debugging (set -x)
- -h, --help display this help and exit successfully
- -o, --output=OFILE leave output in OFILE (implies --clean);
- only one input FILE may be specified in this case
- -q, --quiet no output unless errors (implies --batch)
- -s, --silent same as --quiet
- -v, --version display version information and exit successfully
- -V, --verbose report on what is done
-
-TeX tuning:
- -@ use @input instead of \input for preloaded Texinfo
- --dvi output a DVI file [default]
- -e, -E, --expand force macro expansion using makeinfo
- -I DIR search DIR for Texinfo files
- -l, --language=LANG specify the LANG of FILE (LaTeX or Texinfo)
- --no-line-error do not pass --file-line-error to TeX
- -p, --pdf use pdftex or pdflatex for processing
- -r, --recode call recode before TeX to translate input
- --recode-from=ENC recode from ENC to the @documentencoding
- --src-specials pass --src-specials to TeX
- -t, --command=CMD insert CMD in copy of input file
- or --texinfo=CMD multiple values accumulate
- --translate-file=FILE use given charset translation file for TeX
-
-Build modes:
- --build=MODE specify the treatment of auxiliary files [$build_mode]
- --tidy same as --build=tidy
- -c, --clean same as --build=clean
- --build-dir=DIR specify where the tidy compilation is performed;
- implies --tidy;
- defaults to TEXI2DVI_BUILD_DIRECTORY [$build_dir]
- --mostly-clean remove the auxiliary files and directories
- but not the output
-
-The MODE specifies where the TeX compilation takes place, and, as a
-consequence, how auxiliary files are treated. The build mode
-can also be set using the environment variable TEXI2DVI_BUILD_MODE.
-
-Valid MODEs are:
- \`local' compile in the current directory, leaving all the auxiliary
- files around. This is the traditional TeX use.
- \`tidy' compile in a local *.t2d directory, where the auxiliary files
- are left. Output files are copied back to the original file.
- \`clean' same as \`tidy', but remove the auxiliary directory afterwards.
- Every compilation therefore requires the full cycle.
-
-Using the \`tidy' mode brings several advantages:
- - the current directory is not cluttered with plethora of temporary files.
- - clutter can be even reduced using --build-dir=dir: all the *.t2d
- directories are stored there.
- - clutter can be reduced to zero using, e.g., --build-dir=/tmp/\$USER.t2d
- or --build-dir=\$HOME/.t2d.
- - the output file is updated after every succesful TeX run, for
- sake of concurrent visualization of the output. In a \`local' build
- the viewer stops during the whole TeX run.
- - if the compilation fails, the previous state of the output file
- is preserved.
- - PDF and DVI compilation are kept in separate subdirectories
- preventing any possibility of auxiliary file incompatibility.
-
-On the other hand, because \`tidy' compilation takes place in another
-directory, occasionally TeX won't be able to find some files (e.g., when
-using \\graphicspath): in that case use -I to specify the additional
-directories to consider.
-
-The values of the BIBTEX, LATEX (or PDFLATEX), MAKEINDEX, MAKEINFO,
-TEX (or PDFTEX), TEXINDEX, and THUMBPDF environment variables are used
-to run those commands, if they are set. Any CMD strings are added
-after @setfilename for Texinfo input, in the first line for LaTeX input.
-
-Email bug reports to <bug-texinfo@gnu.org>,
-general questions and discussion to <help-texinfo@gnu.org>.
-Texinfo home page: http://www.gnu.org/software/texinfo/"
-
# Initialize variables for option overriding and otherwise.
# Don't use `unset' since old bourne shells don't have this command.
# Instead, assign them an empty value.
@@ -286,6 +187,34 @@ absolute ()
}
+# ensure_dir DIR1 DIR2...
+# -----------------------
+# Make sure the directories exist.
+ensure_dir ()
+{
+ for dir
+ do
+ test -d "$dir" \
+ || mkdir "$dir" \
+ || error 1 "cannot create directory: $dir"
+ done
+}
+
+
+# error EXIT_STATUS LINE1 LINE2...
+# --------------------------------
+# Report an error and exit with failure if EXIT_STATUS is non null.
+error ()
+{
+ local s="$1"
+ shift
+ report "$@"
+ if test "$s" != 0; then
+ exit $s
+ fi
+}
+
+
# findprog PROG
# -------------
# Return true if PROG is somewhere in PATH, else false.
@@ -323,15 +252,6 @@ report ()
done
}
-# verbose WORD1 WORD2
-# -------------------
-# Report some verbose information.
-verbose ()
-{
- if $verb; then
- echo >&2 "$0: $@"
- fi
-}
# run COMMAND-LINE
# ----------------
@@ -344,30 +264,143 @@ run ()
}
-# error EXIT_STATUS LINE1 LINE2...
-# --------------------------------
-# Report an error and exit with failure if EXIT_STATUS is non null.
-error ()
+# usage
+# -----
+# Display usage and exit successfully.
+usage ()
{
- local s="$1"
- shift
- report "$@"
- if test "$s" != 0; then
- exit $s
+ # We used to simply have `echo "$usage"', but coping with the
+ # changing behavior of `echo' is much harder than simply using a
+ # here-doc.
+ #
+ # echo '\noto' echo '\\noto' echo -e '\\noto'
+ # bash 3.1 \noto \\noto \noto
+ # bash 3.2 %oto \noto -e \noto
+ #
+ # where % denotes the eol character.
+ cat <<EOF
+Usage: $program [OPTION]... FILE...
+
+Run each Texinfo or (La)TeX FILE through TeX in turn until all
+cross-references are resolved, building all indices. The directory
+containing each FILE is searched for included files. The suffix of FILE
+is used to determine its language ((La)TeX or Texinfo). To process
+(e)plain TeX files, set the environment variable LATEX=tex.
+
+In order to make texi2dvi a drop-in replacement of TeX/LaTeX in AUC-TeX,
+the FILE may also be composed of the following simple TeX commands.
+ \`\\input{FILE}' the actual file to compile
+ \`\\nonstopmode' same as --batch
+
+Makeinfo is used to perform Texinfo macro expansion before running TeX
+when needed.
+
+General options:
+ -b, --batch no interaction
+ -D, --debug turn on shell debugging (set -x)
+ -h, --help display this help and exit successfully
+ -o, --output=OFILE leave output in OFILE (implies --clean);
+ only one input FILE may be specified in this case
+ -q, --quiet no output unless errors (implies --batch)
+ -s, --silent same as --quiet
+ -v, --version display version information and exit successfully
+ -V, --verbose report on what is done
+
+TeX tuning:
+ -@ use @input instead of \input for preloaded Texinfo
+ --dvi output a DVI file [default]
+ --dvipdf output a PDF file via DVI (using dvipdf)
+ -e, -E, --expand force macro expansion using makeinfo
+ -I DIR search DIR for Texinfo files
+ -l, --language=LANG specify LANG for FILE, either latex or texinfo
+ --no-line-error do not pass --file-line-error to TeX
+ -p, --pdf use pdftex or pdflatex for processing
+ -r, --recode call recode before TeX to translate input
+ --recode-from=ENC recode from ENC to the @documentencoding
+ --src-specials pass --src-specials to TeX
+ -t, --command=CMD insert CMD in copy of input file
+ or --texinfo=CMD multiple values accumulate
+ --translate-file=FILE use given charset translation file for TeX
+
+Build modes:
+ --build=MODE specify the treatment of auxiliary files [$build_mode]
+ --tidy same as --build=tidy
+ -c, --clean same as --build=clean
+ --build-dir=DIR specify where the tidy compilation is performed;
+ implies --tidy;
+ defaults to TEXI2DVI_BUILD_DIRECTORY [$build_dir]
+ --mostly-clean remove the auxiliary files and directories
+ but not the output
+
+The MODE specifies where the TeX compilation takes place, and, as a
+consequence, how auxiliary files are treated. The build mode
+can also be set using the environment variable TEXI2DVI_BUILD_MODE.
+
+Valid MODEs are:
+ \`local' compile in the current directory, leaving all the auxiliary
+ files around. This is the traditional TeX use.
+ \`tidy' compile in a local *.t2d directory, where the auxiliary files
+ are left. Output files are copied back to the original file.
+ \`clean' same as \`tidy', but remove the auxiliary directory afterwards.
+ Every compilation therefore requires the full cycle.
+
+Using the \`tidy' mode brings several advantages:
+ - the current directory is not cluttered with plethora of temporary files.
+ - clutter can be even reduced using --build-dir=dir: all the *.t2d
+ directories are stored there.
+ - clutter can be reduced to zero using, e.g., --build-dir=/tmp/\$USER.t2d
+ or --build-dir=\$HOME/.t2d.
+ - the output file is updated after every succesful TeX run, for
+ sake of concurrent visualization of the output. In a \`local' build
+ the viewer stops during the whole TeX run.
+ - if the compilation fails, the previous state of the output file
+ is preserved.
+ - PDF and DVI compilation are kept in separate subdirectories
+ preventing any possibility of auxiliary file incompatibility.
+
+On the other hand, because \`tidy' compilation takes place in another
+directory, occasionally TeX won't be able to find some files (e.g., when
+using \\graphicspath): in that case use -I to specify the additional
+directories to consider.
+
+The values of the BIBTEX, LATEX (or PDFLATEX), MAKEINDEX, MAKEINFO,
+TEX (or PDFTEX), TEXINDEX, and THUMBPDF environment variables are used
+to run those commands, if they are set. Any CMD strings are added
+after @setfilename for Texinfo input, in the first line for LaTeX input.
+
+Email bug reports to <bug-texinfo@gnu.org>,
+general questions and discussion to <help-texinfo@gnu.org>.
+Texinfo home page: http://www.gnu.org/software/texinfo/
+EOF
+ exit 0
+}
+
+
+# verbose WORD1 WORD2
+# -------------------
+# Report some verbose information.
+verbose ()
+{
+ if $verb; then
+ echo >&2 "$0: $@"
fi
}
-# ensure_dir DIR1 DIR2...
-# -----------------------
-# Make sure the directories exist.
-ensure_dir ()
+
+# version
+# -------
+# Display version info and exit succesfully.
+version ()
{
- for dir
- do
- test -d "$dir" \
- || mkdir "$dir" \
- || error 1 "cannot create directory: $dir"
- done
+ cat <<EOF
+texi2dvi (GNU Texinfo 4.12+) $rcs_version
+
+Copyright (C) 2008 Free Software Foundation, Inc.
+License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law.
+EOF
+ exit 0
}
@@ -388,6 +421,42 @@ list_append ()
eval $la_l=\""$@"\"
}
+
+# list_concat_dirs LIST-NAME DIR-LIST
+# -----------------------------------
+# Append to LIST-NAME all the components (included empty) from
+# the $path_sep separated list DIR-LIST. Make the paths absolute.
+list_concat_dirs ()
+{
+ local lcd_list="$1"
+ # Empty path components are meaningful to tex. We rewrite them as
+ # `EMPTY' so they don't get lost when we split on $path_sep.
+ # Hopefully no one will have an actual directory named EMPTY.
+ local replace_EMPTY="-e 's/^$path_sep/EMPTY$path_sep/g' \
+ -e 's/$path_sep\$/${path_sep}EMPTY/g' \
+ -e 's/$path_sep$path_sep/${path_sep}EMPTY:/g'"
+ save_IFS=$IFS
+ IFS=$path_sep
+ set x `echo "$2" | eval sed $replace_EMPTY`; shift
+ IFS=$save_IFS
+ local dir
+ for dir
+ do
+ case $dir in
+ EMPTY)
+ list_append $lcd_list ""
+ ;;
+ *)
+ if test -d $dir; then
+ dir=`absolute "$dir"`
+ list_append $lcd_list "$dir"
+ fi
+ ;;
+ esac
+ done
+}
+
+
# list_prefix LIST-NAME SEP -> STRING
# -----------------------------------
# Return a string that is composed of the LIST-NAME with each item
@@ -488,16 +557,15 @@ done
# ---------------------------------------
# Convert relative paths to absolute paths, so we can run in another
# directory (e.g., in tidy build mode, or during the macro-support
-# detection).
-#
-# Empty path components are meaningful to tex. We rewrite them
-# as `EMPTY' so they don't get lost when we split on $path_sep.
-# Hopefully no one will have an actual directory named EMPTY.
+# detection). Prepend ".".
absolute_filenames ()
{
+ # Empty path components are meaningful to tex. We rewrite them as
+ # `EMPTY' so they don't get lost when we split on $path_sep.
+ # Hopefully no one will have an actual directory named EMPTY.
local replace_empty="-e 's/^$path_sep/EMPTY$path_sep/g' \
- -e 's/$path_sep\$/${path_sep}EMPTY/g' \
- -e 's/$path_sep$path_sep/${path_sep}EMPTY:/g'"
+ -e 's/$path_sep\$/${path_sep}EMPTY/g' \
+ -e 's/$path_sep$path_sep/${path_sep}EMPTY:/g'"
local res
res=`echo "$1" | eval sed $replace_empty`
save_IFS=$IFS
@@ -511,8 +579,14 @@ absolute_filenames ()
res=$res$path_sep
;;
*)
- if test -d $dir; then
+ if test -d "$dir"; then
res=$res$path_sep`absolute "$dir"`
+ else
+ # Even if $dir is not a directory, preserve it in the path.
+ # It might contain metacharacters that TeX will expand in
+ # turn, e.g., /some/path/{a,b,c}. This will not get the
+ # implicit absolutification of the path, but we can't help that.
+ res=$res$path_sep$dir
fi
;;
esac
@@ -694,16 +768,18 @@ generated_files_get ()
fi
;;
latex)
- # bibtex: *.aux -> *.bbl and *.blg.
if aux_file_p $file; then
+ # bibtex: *.aux -> *.bbl and *.blg.
echo $file | sed 's/^\(.*\)\.aux$/\1.bbl/'
- echo $file | sed 's/^\(.*\)\.aux$/\1.blg/'
+ echo $file | sed 's/^\(.*\)\.aux$/\1.blg/'
+ # -recorder: .fls
+ echo $file | sed 's/^\(.*\)\.aux$/\1.fls/'
fi
;;
esac
done |
# Filter existing files matching the criterion.
- #
+ #
# With an input file name containing a space, this produces a
# "command not found" message (and filtering is ineffective).
# The situation with a newline is presumably even worse.
@@ -730,6 +806,10 @@ xref_files_save ()
# The following line improves `cp $xref_files_orig "$work_bak"'
# by preserving the directory parts. Think of
# cp chap1/main.aux chap2/main.aux $work_bak.
+ #
+ # Users may have, e.g., --keep-old-files. Don't let this interfere.
+ # (Don't use unset for the sake of ancient shells.)
+ TAR_OPTIONS=; export TAR_OPTIONS
tar cf - $xref_files_orig | (cd "$work_bak" && tar xf -)
fi
}
@@ -853,26 +933,26 @@ run_tex ()
# we'd like to handle arbitrary input file names, such as a~b.tex.
# This isn't a general way to do it :), though it does work, kind of.
# cmd="$cmd '${escape}catcode126=12 \input '"
-
+
# TeX's \input does not (easily or reliably) support whitespace
# characters or other special characters in file names. Our intensive
# use of absolute file names makes this worse: the enclosing directory
# names may include white spaces. Improve the situation using a
# symbolic link to the filename in the current directory, in tidy mode
# only. Do not alter in_input.
- #
+ #
# The filename is almost always tokenized using plain TeX conventions
# (the exception would be if the user made a texinfo.fmt file). Not
# all the plain TeX special characters cause trouble, but there's no
# harm in making the link.
- #
+ #
case $tidy:`func_dirname "$in_input"` in
true:*["$space$tab$newline\"#\$%\\^_{}"]*)
_run_tex_file_name=`basename "$in_input"`
if test ! -f "$_run_tex_file_name"; then
- verbose ln -s "$in_input"
- rm -f "$_run_tex_file_name"
- ln -s "$_run_tex_file_name"
+ # It might not be a file, clear it.
+ run rm -f "$_run_tex_file_name"
+ run ln -s "$in_input"
fi
cmd="$cmd '$_run_tex_file_name'"
;;
@@ -1094,8 +1174,8 @@ uncomment_iftex='s/^@c texi2dvi//'
# main info output, the user asked to run TeX, not makeinfo.
run_makeinfo ()
{
- test $in_lang == texinfo ||
- return 0
+ test $in_lang = texinfo \
+ || return 0
# Unless required by the user, makeinfo expansion is wanted only
# if texinfo.tex is too old.
@@ -1333,7 +1413,7 @@ compile ()
eval val="\$common\$${var}_orig"
# Convert relative paths to absolute paths, so we can run in another
# directory (e.g., in clean build mode, or during the macro-support
- # detection).
+ # detection). ".:" is added here.
val=`absolute_filenames "$val"`
eval $var="\"$val\""
export $var
@@ -1436,14 +1516,9 @@ while test x"$1" != x"$arg_sep"; do
--dvi) out_lang=dvi;;
--dvipdf) out_lang=dvipdf;;
-e | -E | --expand) expand=t;;
- -h | --help) echo "$usage"; exit 0;;
+ -h | --help) usage;;
--html) out_lang=html;;
- -I | --I*)
- shift
- # Use absolute dir names in the includes.
- val=`absolute "$1"`
- list_append includes "$val"
- ;;
+ -I) shift; list_concat_dirs includes "$1";;
--info) out_lang=info;;
-l | --lang | --language) shift; set_language=$1;;
--mostly-clean) action=mostly-clean;;
@@ -1463,7 +1538,7 @@ while test x"$1" != x"$arg_sep"; do
--text) out_lang=text;;
--translate-file ) shift; translate_file="$1";;
--tidy) build_mode=tidy;;
- -v | --vers*) echo "$version"; exit 0;;
+ -v | --vers*) version;;
-V | --verb*) verb=true;;
--) # What remains are not options.
shift