bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

texi2dvi -b not so batch


From: Akim Demaille
Subject: texi2dvi -b not so batch
Date: Wed, 09 Feb 2005 10:02:40 +0100
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.3 (gnu/linux)

TeX really does not want to run in batch mode :(  So this patch makes
it shut its hears when asked to.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * util/texi2dvi: More uses of the verbose function.
        (run_tex): New function to factor the two tex invocations.
        Move the handling of tex arguments in here to improve locallity.
        Enforce the batch mode by closing its stdin.

Index: util/texi2dvi
===================================================================
RCS file: /cvsroot/texinfo/texinfo/util/texi2dvi,v
retrieving revision 1.40
diff -u -u -r1.40 texi2dvi
--- util/texi2dvi 28 Jan 2005 14:41:58 -0000 1.40
+++ util/texi2dvi 9 Feb 2005 09:00:12 -0000
@@ -150,7 +150,7 @@
 # Report an error and exit with failure.
 fatal ()
 {
-  echo >&2 "$0: $*"
+  verbose "$@"
   exit 1
 }
 
@@ -224,8 +224,8 @@
       done
       break;;
     -*)
-      echo "$0: Unknown or ambiguous option \`$1'." >&2
-      echo "$0: Try \`--help' for more information." >&2
+      verbose "Unknown or ambiguous option \`$1'."
+      verbose "Try \`--help' for more information."
       exit 1;;
     *) set dummy ${1+"$@"} "$1"; shift;;
    esac
@@ -237,14 +237,14 @@
 # Interpret remaining command line args as filenames.
 case $# in
  0)
-  echo "$0: Missing file arguments." >&2
-  echo "$0: Try \`--help' for more information." >&2
+  verbose "Missing file arguments."
+  verbose "Try \`--help' for more information."
   exit 2
   ;;
  1) ;;
  *)
   if test -n "$oname"; then
-    echo "$0: Can't use option \`--output' with more than one argument." >&2
+    verbose "Can't use option \`--output' with more than one argument."
     exit 2
   fi
   ;;
@@ -393,6 +393,42 @@
   echo "$_res"
 }
 
+
+# run_tex ()
+# ----------
+# Run TeX as "$tex $tex_args $filename_input", taking care of errors
+# and logs.
+run_tex ()
+{
+  # Note that this will be used via an eval: quote properly.
+  cmd=$tex
+
+  # If possible, make TeX report error locations in GNU format.
+  tex_args=
+  case $tex_help in
+    *file-line-error*) cmd="$cmd --file-line-error";;
+  esac
+
+  # Tell TeX to be batch if requested.
+  if $batch; then
+    # \batchmode does not show terminal output at all, so we don't
+    # want that.  And even in batch mode, TeX insists on having input
+    # from the user.  Close its stdin to make it impossible.
+    cmd="$cmd <&- '${escape}nonstopmode' '${escape}input'"
+  fi
+
+  cmd="$cmd '$filename_input'"
+
+  verbose "Running $cmd ..."
+  if eval "$cmd" >&5; then :; else
+    verbose "$tex exited with bad status, quitting."
+    verbose "see $filename_noext.log for errors."
+    test "$clean" = t \
+        && cp "$filename_noext.log" "$orig_pwd"
+    exit 1
+  fi
+}
+
 # File descriptor usage:
 # 0 standard input
 # 1 standard output (--verbose messages)
@@ -432,7 +468,7 @@
   # prompt (assuming they're attending the terminal), this script won't
   # be able to find the right xref files and so forth.
   if test ! -r "$command_line_filename"; then
-    echo "$0: Could not read $command_line_filename, skipping." >&2
+    verbose "Could not read $command_line_filename, skipping."
     continue
   fi
 
@@ -577,16 +613,6 @@
   # --help will generate a texput.log.
   tex_help=`cd $tmpdir >/dev/null && $tex --help </dev/null 2>&1`
 
-  # If possible, make TeX report error locations in GNU format.
-  tex_args=
-  case $tex_help in
-    *file-line-error*) tex_args="$tex_args --file-line-error";;
-  esac
-
-  # Tell TeX to be batch if requested.  (\batchmode does not show
-  # terminal output at all, so we don't want that.)
-  $batch && tex_args="$tex_args ${escape}nonstopmode ${escape}input"
-
   # Expand macro commands in the original source file using Makeinfo.
   # Always use `end' footnote style, since the `separate' style
   #   generates different output (arguably this is a bug in -E).
@@ -703,16 +729,7 @@
     fi
 
     # Finally, run TeX.
-    cmd="$tex $tex_args"
-    verbose "Running $cmd $filename_input ..."
-    if $cmd "$filename_input" >&5; then :; else
-      echo "$0: $tex exited with bad status, quitting." >&2
-      echo "$0: see $filename_noext.log for errors." >&2
-      test "$clean" = t \
-        && cp "$filename_noext.log" "$orig_pwd"
-      exit 1
-    fi
-
+    run_tex
 
     # Decide if looping again is needed.
     finished=t
@@ -766,15 +783,7 @@
     verbose "Running $thumbpdf $filename_noext ..."
     $thumbpdf "$filename_noext" >&5 ||
       fatal "$thumbpdf exited with bad status, quitting."
-
-    verbose "Running $cmd $filename_input..."
-    if $cmd "$filename_input" >&5; then :; else
-      echo "$0: $tex exited with bad status, quitting." >&2
-      echo "$0: see $filename_noext.log for errors." >&2
-      test "$clean" = t \
-       && cp "$filename_noext.log" "$orig_pwd"
-      exit 1
-    fi
+    run_tex
   fi
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]