1#!/bin/sh
2# $Id: texconfig.sh 34586 2014-07-13 00:06:11Z karl $
3# texconfig version 3.0
4# Originally written by Thomas Esser. Public domain.
5# Now maintained as part of TeX Live; correspondence to tex-live@tug.org.
6
7# invoke the right shell:
8
9test -f /bin/ksh && test -z "$RUNNING_KSH" \
10  && { UNAMES=`uname -s`; test "x$UNAMES" = xULTRIX; } 2>/dev/null \
11  && { RUNNING_KSH=true; export RUNNING_KSH; exec /bin/ksh $0 ${1+"$@"}; }
12unset RUNNING_KSH
13
14test -f /bin/bsh && test -z "$RUNNING_BSH" \
15  && { UNAMES=`uname -s`; test "x$UNAMES" = xAIX; } 2>/dev/null \
16  && { RUNNING_BSH=true; export RUNNING_BSH; exec /bin/bsh $0 ${1+"$@"}; }
17unset RUNNING_BSH
18
19# hack around a bug in zsh:
20test -n "${ZSH_VERSION+set}" && alias -g '${1+"$@"}'='"$@"'
21
22# preferentially use subprograms from our own directory.
23mydir=`echo "$0" | sed 's,/[^/]*$,,'`
24mydir=`cd "$mydir" && pwd`
25PATH="$mydir:$PATH"; export PATH
26
27# initializations...
28progname=texconfig
29
30# the version string
31version='$Id: texconfig.sh 34586 2014-07-13 00:06:11Z karl $'
32
33envVars="
34  AFMFONTS BIBINPUTS BSTINPUTS CMAPFONTS CWEBINPUTS ENCFONTS GFFONTS
35  GLYPHFONTS INDEXSTYLE LIGFONTS MFBASES MFINPUTS MFPOOL MFTINPUTS
36  MISCFONTS MPINPUTS MPMEMS MPPOOL MPSUPPORT OCPINPUTS OFMFONTS
37  OPENTYPEFONTS OPLFONTS OTPINPUTS OVFFONTS OVPFONTS PDFTEXCONFIG PKFONTS
38  PSHEADERS SFDFONTS T1FONTS T1INPUTS T42FONTS TEXBIB TEXCONFIG TEXDOCS
39  TEXFONTMAPS TEXFONTS TEXFORMATS TEXINDEXSTYLE TEXINPUTS TEXMFCNF
40  TEXMFDBS TEXMFINI TEXMFSCRIPTS TEXPICTS TEXPKS TEXPOOL TEXPSHEADERS
41  TEXSOURCES TFMFONTS TRFONTS TTFONTS VFFONTS WEB2C WEBINPUTS
42"
43tmpdir=${TMPDIR-${TEMP-${TMP-/tmp}}}/tctmp.$$
44needsCleanup=false
45lastUpdatedFile=
46
47#
48###############################################################################
49# setupFMT(void) - find a suitable version of fmt / adjust
50#
51setupFMT()
52{
53  case $FMT in
54    "")
55      FMT=fmt
56      test ! -x /bin/fmt && test ! -f /usr/bin/fmt &&
57        { test -x /bin/adjust || test -x /usr/bin/adjust; } && FMT=adjust
58      ;;
59    *)
60      return
61      ;;
62  esac
63}
64
65###############################################################################
66# myFmt(args) - run $FMT
67#
68myFmt()
69{
70  setupFMT
71  $FMT ${1+"$@"}
72}
73
74###############################################################################
75# echoShowVariable(args ...)
76#   show environment variables which names are as args and their values
77#
78echoShowVariable()
79{
80  for esv
81  do
82    var=$esv
83    eval val=\"\${$var+=}\${$var- is unset}\"
84    echo "$var$val"
85  done | grep -v 'is unset$'
86}
87
88###############################################################################
89# echoShowKpseVariable(args ...)
90#   show kpathsea variables which names are as args and their values
91#
92echoShowKpseVariable()
93{
94  for eskv
95  do
96    var=$eskv
97    val=`kpsewhich -var-value="$eskv"`
98    echo "$var=$val"
99  done
100}
101
102###############################################################################
103# echoLocateBinary(args ...) - show where programs actually exist
104#
105echoLocateBinary()
106{
107  for elb
108  do
109    elbLoc=`checkForBinary "$elb"`
110    if test -n "$ELB_PATH_ONLY"; then
111      test -n "$elbLoc" && echo "$elbLoc"
112    else
113      case $elbLoc in
114        "") echo "$elb: not found";;
115        *) echo "$elb: $elbLoc";;
116      esac
117    fi
118  done
119}
120
121###############################################################################
122# echoLocateCfgfile(args ...) - show where files actually exist
123#
124echoLocateCfgfile()
125{
126  for elc
127  do
128    case $elc in
129      texmf.cnf) elcLoc=`kpsewhich $elc`;;
130      *) elcLoc=`tcfmgr --cmd find --file "$elc"`;;
131    esac
132    case $elcLoc in
133      "") echo "$elc: not found";;
134      *)  echo "$elcLoc";;
135    esac
136  done
137}
138
139###############################################################################
140# checkForBinary(prog) - echo full path of prog
141#
142checkForBinary()
143{
144  cfbBinary=$1
145
146  OLDIFS=$IFS
147  IFS=:
148  set x `echo "$PATH" | sed 's/^:/.:/; s/:$/:./; s/::/:.:/g'`; shift
149  found=false
150  for pathElem
151  do
152    case $pathElem in
153      "") continue;;
154      *) test -f "$pathElem/$cfbBinary" && { echo "$pathElem/$cfbBinary"; found=true; break; }
155    esac
156  done
157  IFS=$OLDIFS
158  case $found in
159    true) (exit 0); return 0;;
160    false) (exit 1); return 1;;
161  esac
162}
163
164###############################################################################
165# cleanup() - clean up the temp area and exit with proper exit status
166#
167cleanup()
168{
169  rc=$1
170  $needsCleanup && test -n "$tmpdir" && test -d "$tmpdir" \
171    && { cd / && rm -rf "$tmpdir"; }
172  (exit $rc); exit $rc
173}
174
175###############################################################################
176# setupTmpDir() - set up a temp directory and a trap to remove it
177#
178setupTmpDir()
179{
180  case $needsCleanup in
181    true) return;;
182  esac
183
184  trap 'cleanup 1' 1 2 3 7 13 15
185  needsCleanup=true
186  (umask 077; mkdir "$tmpdir") \
187    || abort "could not create directory \`$tmpdir'"
188}
189
190###############################################################################
191# setupTexmfmain() - get value for MT_TEXMFMAIN (with caching)
192#
193setupTexmfmain()
194{
195  case $MT_TEXMFMAIN in
196    "") MT_TEXMFMAIN=`kpsewhich -var-value=TEXMFMAIN`;;
197    *) return;;
198  esac
199}
200
201###############################################################################
202# setupTexmfmain() - get value for MT_TEXMFDIST (with caching)
203#
204setupTexmfdist()
205{
206  case $MT_TEXMFDIST in
207    "") MT_TEXMFDIST=`kpsewhich -var-value=TEXMFDIST`;;
208    *) return;;
209  esac
210}
211
212###############################################################################
213# setupTexmfvar() - get value for MT_TEXMFVAR (with caching)
214#
215setupTexmfvar()
216{
217  case $MT_TEXMVAR in
218    "") MT_TEXMVAR=`kpsewhich -var-value=TEXMFVAR`;;
219    *) return;;
220  esac
221}
222
223###############################################################################
224# setupSystexmf() - get value for MT_SYSTEXMF (with caching)
225#
226setupSystexmf()
227{
228  case $MT_SYSTEXMF in
229    "") MT_SYSTEXMF=`kpsewhich -var-value=SYSTEXMF`;;
230    *) return;;
231  esac
232}
233
234###############################################################################
235# abort(errmsg)
236#   print `errmsg' to stderr and exit with error code 1
237#
238abort()
239{
240  echo "$progname: $1." >&2
241  cleanup 1
242}
243
244###############################################################################
245# mktexdir(args)
246#   call mktexdir script, disable all features (to prevent sticky directories)
247#
248mktexdir()
249{
250  setupTexmfmain
251  MT_FEATURES=none "$MT_TEXMFMAIN/web2c/mktexdir" "$@" >&2
252}
253
254###############################################################################
255# tcfmgr(args) - call tcfmgr script
256#
257tcfmgr()
258{
259  setupTexmfmain
260  "$MT_TEXMFMAIN/texconfig/tcfmgr" "$@"
261}
262
263###############################################################################
264# mktexupd(args) - call mktexupd script
265#
266mktexupd()
267{
268  setupTexmfmain
269  "$MT_TEXMFMAIN/web2c/mktexupd" "$@"
270}
271
272###############################################################################
273# getRelDir(file)
274#   matches file against SYSTEXMF. Returns relative directory of file within
275#   a texmf tree in variable relPart.
276#
277getRelDir()
278{
279  file=$1
280  relPart=
281
282  setupSystexmf
283  OLDIFS=$IFS
284  IFS='
285'
286  set x `echo "$MT_SYSTEXMF" | tr : '
287'`; shift
288  IFS=$OLDIFS
289
290  # now loop over all components of SYSTEXMF
291  for dir
292  do
293    test -n "$dir" || continue
294    case "$file" in
295      $dir/*)
296        relPart=`echo "$file" | sed "s%$dir/*%%"`
297        break
298        ;;
299    esac
300  done
301
302  # now check for success / failure
303  case $relPart in
304    ""|$file)
305      # empty or full filename -> getRelDir failed!
306      (exit 1); return 1
307      ;;
308    *)
309      # relPart should just have the "dirname" part:
310      relPart=`echo "$relPart" | sed 's%/*[^/]*$%%'`
311      (exit 0); return 0
312      ;;
313  esac
314}
315
316###############################################################################
317# configReplace(file pattern line)
318#   The first line in file that matches pattern gets replaced by line.
319#   line will be added at the end of the file if pattern does not match.
320#
321configReplace()
322{
323  configReplaceFile=$1; configReplacePat=$2; configReplaceLine=$3
324
325  if grep "$configReplacePat" "$configReplaceFile" >/dev/null; then
326    ed "$configReplaceFile" >/dev/null 2>&1 <<-eof
327	/$configReplacePat/c
328	$configReplaceLine
329	.
330	w
331	q
332eof
333  else
334    echo "$configReplaceLine" >> $configReplaceFile
335  fi
336}
337
338###############################################################################
339# fmgrConfigReplace (file regex value)
340#   replaces line matching regex by value in file
341#
342fmgrConfigReplace()
343{
344  fmgrConfigReplaceChanged=false
345
346  moreArgs=""
347  while
348    case $1 in
349      --*) moreArgs="$moreArgs $1 $2";;
350      *) break;;
351    esac
352  do shift; shift; done
353  fmgrConfigReplaceFile=$1
354  fmgrConfigReplaceRegex=$2
355  fmgrConfigReplaceValue=$3
356
357  setupTmpDir
358  co=`tcfmgr $moreArgs --tmp $tmpdir --cmd co --file $fmgrConfigReplaceFile`
359  if test $? != 0; then
360    echo "$progname: fmgrConfigReplace co failed for \`$fmgrConfigReplaceFile'" >&2
361    (exit 1); return 1
362  fi
363  set x $co; shift
364  fmgrConfigReplaceID=$1; fmgrConfigReplaceCfgFile=$3; fmgrConfigReplaceOrigFile=$4
365  configReplace "$fmgrConfigReplaceCfgFile" "$fmgrConfigReplaceRegex" "$fmgrConfigReplaceValue"
366  ci=`tcfmgr --tmp $tmpdir --cmd ci --id "$fmgrConfigReplaceID"`
367  if test $? != 0; then
368    echo "$progname: fmgrConfigReplace ci failed for \`$fmgrConfigReplaceFile'" >&2
369    (exit 1); return 1
370  fi
371  case $ci in
372    "") :;;
373    $lastUpdatedFile)
374      fmgrConfigReplaceChanged=true;;
375    *) echo "$progname: updated configuration saved as file \`$ci'" >&2
376       fmgrConfigReplaceChanged=true
377       lastUpdatedFile=$ci;;
378  esac
379  (exit 0); return 0
380}
381
382###############################################################################
383# setupDvipsPaper(paper)
384#   rearranges config.ps to make paper the first paper definition
385#
386setupDvipsPaper()
387{
388  setupDvipsPaperChanged=false
389  setupDvipsPaperFile=config.ps
390  setupDvipsPaperDftPaper=$1
391
392  setupTmpDir
393  co=`tcfmgr --tmp $tmpdir --cmd co --file $setupDvipsPaperFile`
394  if test $? != 0; then
395    echo "$progname: setupDvipsPaper co failed for \`$setupDvipsPaperFile'" >&2
396    (exit 1); return 1
397  fi
398  set x $co; shift
399  setupDvipsPaperID=$1; setupDvipsPaperCfgFile=$3; setupDvipsPaperOrigFile=$4
400
401  ed "$setupDvipsPaperCfgFile" > /dev/null 2>&1 <<-eof
402	/@ /ka
403	\$a
404	@ 
405	.
406	/@ $setupDvipsPaperDftPaper /;/@ /-1m'a-1
407	\$d
408	w
409	q
410eof
411
412  ci=`tcfmgr --tmp $tmpdir --cmd ci --id "$setupDvipsPaperID"`
413  if test $? != 0; then
414    echo "$progname: setupDvipsPaper ci failed for \`$setupDvipsPaperFile'" >&2
415    (exit 1); return 1
416  fi
417  case $ci in
418    "") :;;
419    $lastUpdatedFile)
420      setupDvipsPaperChanged=true;;
421    *) echo "$progname: updated configuration saved as file \`$ci'" >&2
422       setupDvipsPaperChanged=true
423       lastUpdatedFile=$ci;;
424  esac
425  (exit 0); return 0
426}
427
428###############################################################################
429# setupModesMfFile(void) - find modes.mf file (with caching)
430#
431setupModesMfFile()
432{
433  case $modesMfFile in
434    "")
435      modesMfFile=`tcfmgr --cmd find --file modes.mf`
436      ;;
437    *)
438      return
439      ;;
440  esac
441}
442
443###############################################################################
444# locateConfigPsFile(void) - find config.ps file (with caching)
445#
446locateConfigPsFile()
447{
448  case $configPsFile in
449    "")
450      configPsFile=`tcfmgr --cmd find --file config.ps`
451      ;;
452    *)
453      return
454      ;;
455  esac
456}
457
458###############################################################################
459# listMfModes(file) - list modes from modes.mf file
460#
461listMfModes()
462{
463  grep mode_def "$modesMfFile" |
464  sed -e "s/mode_def //" \
465      -e "s/ .*%[^ ]* / '/" \
466      -e "s/\$/' /" |
467  egrep -v "^(help|%)" | sort
468}
469
470###############################################################################
471# listDvipsPapers(void) - list paper definitions from config.ps
472#
473listDvipsPapers()
474{
475  grep '@ ' $configPsFile | sed "s/..//;s/ / '/;s/\$/' /"
476}
477
478###############################################################################
479# getFormatsForHyphen(void)
480#   list all formats which have customizable hyphenation
481#
482getFormatsForHyphen()
483{
484  fmtutil --catcfg | awk '$3 != "-" {print $1}' | sort
485}
486
487###############################################################################
488# getRes(mode) - print resolution (both X and Y axis) to metafont mode
489#
490getRes()
491{
492  getResMode=$1
493  (
494    cd $tmpdir
495    cat >mftmp.mf <<-'eof'
496	let myexit = primitive_end_;
497	mode_setup;
498	string xdpi;
499	xdpi := decimal round pixels_per_inch;
500	message "XDPI = " & xdpi;
501	string ydpi;
502	ydpi := decimal round (pixels_per_inch * aspect_ratio);
503	message "YDPI = " & ydpi;
504	fontmaking := 0;
505	myexit;
506eof
507    mf '\mode='"$getResMode"';  \input ./mftmp' </dev/null \
508     | awk '$1 == "XDPI" || $1 == "YDPI" { print $3 }'
509  )
510}
511
512###############################################################################
513# checkElemInList(elem, list)
514#   check if element exists in list
515###############################################################################
516checkElemInList()
517{
518  checkElemInListElem=$1; shift
519  checkElemInListFound=false
520  for checkElemInListIter
521  do
522    case "x$checkElemInListElem" in
523      x$checkElemInListIter)
524        checkElemInListFound=true
525        break
526        ;;
527    esac
528  done
529  case $checkElemInListFound in
530    true) (exit 0); return 0;;
531  esac
532  (exit 1); return 1
533}
534
535
536# show version information from the distribution, if we have any.
537showDistVersionInfo()
538{
539  # TeX Live file.
540  test -f $MT_TEXMFMAIN/../release-texlive.txt \
541  && sed 1q $MT_TEXMFMAIN/../release-texlive.txt
542
543  # no harm in continuing to look for the teTeX files.
544  test -f $MT_TEXMFMAIN/release-tetex-src.txt \
545  && "teTeX-src release:   `cat $MT_TEXMFMAIN/release-tetex-src.txt`"
546  test -f $MT_TEXMFDIST/release-tetex-texmf.txt \
547  && "teTeX-texmf release: `cat $MT_TEXMFDIST/release-tetex-texmf.txt`"
548}
549
550#
551###############################################################################
552# tcBatch(args)
553#   handle batch mode
554###############################################################################
555tcBatch()
556{
557  help="texconfig supports adjusting and updating many aspects of
558the TeX installation.
559
560Usage: $progname conf                  (show configuration information)
561       $progname dvipdfmx paper PAPER  (dvipdfmx paper size)
562       $progname dvipdfm paper PAPER   (dvipdfm paper size)
563       $progname dvips [OPTION...]     (dvips options)
564       $progname faq                   (show teTeX faq)
565       $progname findprog PROG...      (show locations of PROGs, a la which)
566       $progname font vardir DIR
567       $progname font ro
568       $progname font rw
569       $progname formats               (edit fmtutil.cnf)
570       $progname help                  (or --help; show this help)
571       $progname hyphen FORMAT         (edit hyphenation config for FORMAT)
572       $progname init [FORMAT]...      (rebuild FORMATs, or all formats
573                                        plus run texlinks and updmap)
574       $progname mode MODE             (set Metafont MODE)
575       $progname paper PAPER           (set default paper size to PAPER)
576       $progname pdftex [OPTION]...    (pdftex options)
577       $progname rehash                (rebuild ls-R files with mktexlsr)
578       $progname version               (or --version; show version info)
579       $progname xdvi paper PAPER      (xdvi paper size)
580
581Get more help with:
582       $progname dvipdfmx
583       $progname dvipdfm
584       $progname dvips
585       $progname font
586       $progname hyphen
587       $progname mode
588       $progname paper
589       $progname pdftex
590       $progname xdvi
591
592Report bugs to: tex-k@tug.org
593TeX Live home page: <http://tug.org/texlive/>
594"
595
596  case $1 in
597    # texconfig conf
598    conf|confall)
599      setupTexmfmain
600      setupTexmfdist
601      echo '=========================== version information =========================='
602      showDistVersionInfo
603      echo
604      echo '==================== binaries found by searching $PATH ==================='
605      echo "PATH=$PATH"
606      echoLocateBinary kpsewhich updmap fmtutil texconfig tex pdftex mktexpk dvips dvipdfm
607      echo
608      echo '=========================== active config files =========================='
609      echoLocateCfgfile texmf.cnf updmap.cfg fmtutil.cnf config.ps mktex.cnf XDvi pdftexconfig.tex config | sort -k 2
610      echo
611      echo '============================= font map files ============================='
612      for m in psfonts.map pdftex.map ps2pk.map dvipdfm.map; do
613        echo "$m: `kpsewhich $m`"
614      done
615      echo
616      echo '=========================== kpathsea variables ==========================='
617      echoShowKpseVariable TEXMFMAIN TEXMFDIST TEXMFLOCAL TEXMFSYSVAR TEXMFSYSCONFIG TEXMFVAR TEXMFCONFIG TEXMFHOME VARTEXFONTS TEXMF SYSTEXMF TEXMFDBS WEB2C TEXPSHEADERS TEXCONFIG ENCFONTS TEXFONTMAPS
618
619      echo
620      echo '==== kpathsea variables from environment only (ok if no output here) ===='
621      echoShowVariable $envVars
622      ;;
623
624    # texconfig dvipdfm
625    dvipdfm)
626      help="Usage: $progname dvipdfm paper PAPER
627
628Valid PAPER settings:
629  letter legal ledger tabloid a4 a3"
630      case $2 in
631        # texconfig dvipdfm paper
632        paper-list)
633          for p in letter legal ledger tabloid a4 a3; do echo $p; done
634          ;;
635        paper)
636          case $3 in
637            letter|legal|ledger|tabloid|a4|a3)
638              fmgrConfigReplace config '^p' "p $3";;
639            "") echo "$help" >&2; rc=1;;
640            *)
641             echo "$progname: unknown PAPER \`$3' given as argument for \`$progname dvipdfm paper'" >&2
642             echo "$progname: try \`$progname dvipdfm paper' for help" >&2
643             rc=1 ;;
644          esac ;;
645        # texconfig dvipdfm ""
646        "")
647          echo "$help" >&2; rc=1 ;;
648        # texconfig dvipdfm <unknown>
649        *)
650          echo "$progname: unknown option \`$2' given as argument for \`$progname dvipdfm'" >&2
651          echo "$progname: try \`$progname dvipdfm' for help" >&2
652          rc=1
653          ;;
654      esac
655      ;;
656
657    # texconfig dvipdfmx
658    dvipdfmx)
659      help="Usage: $progname dvipdfmx paper PAPER
660
661Valid PAPER settings:
662  letter legal ledger tabloid a4 a3"
663      case $2 in
664        # texconfig dvipdfmx paper
665        paper-list)
666          for p in letter legal ledger tabloid a4 a3; do echo $p; done
667          ;;
668        paper)
669          case $3 in
670            letter|legal|ledger|tabloid|a4|a3)
671              fmgrConfigReplace dvipdfmx.cfg '^p' "p $3";;
672            "") echo "$help" >&2; rc=1;;
673            *)
674             echo "$progname: unknown PAPER \`$3' given as argument for \`$progname dvipdfmx paper'" >&2
675             echo "$progname: try \`$progname dvipdfmx paper' for help" >&2
676             rc=1 ;;
677          esac ;;
678        # texconfig dvipdfmx ""
679        "")
680          echo "$help" >&2; rc=1 ;;
681        # texconfig dvipdfmx <unknown>
682        *)
683          echo "$progname: unknown option \`$2' given as argument for \`$progname dvipdfmx'" >&2
684          echo "$progname: try \`$progname dvipdfmx' for help" >&2
685          rc=1
686          ;;
687      esac
688      ;;
689
690    # texconfig dvips
691    dvips)
692      shift
693      help="Usage: $progname dvips add PRINTER
694       $progname dvips del PRINTER
695       $progname dvips paper PAPER
696       $progname dvips [-P PRINTER] mode MODE
697       $progname dvips [-P PRINTER] offset OFFSET
698       $progname dvips [-P PRINTER] printcmd CMD"
699      case $1 in
700        -P)
701          case $2 in
702            "")
703              echo "$progname: missing arg for parameter -P" >&2
704              rc=1; (exit $rc); return $rc
705              ;;
706            *)
707              otherPrinter=true
708              otherPrinterName=$2
709              otherPrinterFile=`kpsewhich -format='dvips config' "config.$otherPrinterName"`
710              case $otherPrinterFile in
711                "")
712                  echo "$progname: configuration file \`config.$otherPrinterName' for printer \`$otherPrinterName' not found" >&2
713                  rc=1; (exit $rc); return $rc
714                  ;;
715                *) shift; shift;;
716              esac
717              ;;
718          esac
719          ;;
720        *)
721          otherPrinter=false
722          ;;
723      esac
724      case $otherPrinter in
725        true)
726          tcBatchDvipsPrinter=$otherPrinterName
727          moreFmgrArgs="--reldir dvips/config --infile $otherPrinterFile"
728          ;;
729        *)
730          tcBatchDvipsPrinter=ps
731          ;;
732      esac
733      case $1 in
734        add)
735          case $2 in
736            "")
737              echo "Usage: $progname dvips add PRINTER" >&2
738              rc=1
739              ;;
740            *)
741              printerName=$2
742              pFile=`kpsewhich -format='dvips config' "config.$printerName"`
743              case $pFile in
744                "")
745                  setupTmpDir
746                  tcfRet=`tcfmgr --emptyinfile --reldir dvips/config --cmd co --tmp $tmpdir --file "config.$printerName"`
747                  if test $? != 0; then
748                    echo "$progname: failed to add new configuration file \`config.$printerName'" >&2
749                    rc=1
750                  else
751                    set x $tcfRet; shift
752                    tcBatchDvipsAddID=$1; tcBatchDvipsAddFile=$3
753                    echo "% file config.$printerName; added by texconfig" > "$tcBatchDvipsAddFile"
754                    tcfRet=`tcfmgr --tmp $tmpdir --id "$tcBatchDvipsAddID" --cmd ci`
755                    if test $? != 0; then
756                      echo "$progname: failed to add new configuration file \`config.$printerName'" >&2
757                      rc=1
758                    else
759                      echo "$progname: file $tcfRet added" >&2
760                    fi
761                  fi
762                  ;;
763                *)
764                  echo "$progname: configuration file for printer \`$printerName' already exists (\`$pFile')" >&2
765                  rc=1
766                  ;;
767              esac
768              ;;
769          esac
770          ;;
771        del)
772          case $2 in
773            "")
774              echo "Usage: $progname dvips del PRINTER" >&2
775              rc=1
776              ;;
777            *)
778              printerName=$2
779              pFile=`kpsewhich -format='dvips config' "config.$printerName"`
780              case $pFile in
781                "")
782                  echo "$progname: configuration file for printer \`$printerName' (config.$printerName) not found" >&2
783                  rc=1
784                  ;;
785                *)
786                  if rm "$pFile"; then
787                    echo "$progname: file \`$pFile' removed" >&2
788                  else
789                    echo "$progname: failed to remove file \`$pFile'" >&2
790                    rc=1
791                  fi
792                  ;;
793              esac
794              ;;
795          esac
796          ;;
797        paper-list)
798          locateConfigPsFile
799          listDvipsPapers
800          ;;
801        paper)
802          case $2 in
803            "")
804              echo "Usage: $progname dvips paper PAPER" >&2
805              echo >&2; echo "Valid PAPER settings:" >&2
806              locateConfigPsFile
807              listDvipsPapers | sed 's@ .*@@; s@^@  @' | myFmt
808              rc=1
809              ;;
810            *)
811              tcBatchDvipsPaper=$2
812              locateConfigPsFile
813              case "$configPsFile" in
814                "")
815                  echo "$progname: file config.ps not found" >&2; rc=1
816                  ;;
817                *)
818                  if grep "@ $tcBatchDvipsPaper " $configPsFile >/dev/null 2>&1; then
819                    setupDvipsPaper "$tcBatchDvipsPaper"
820                  else
821                    echo "$progname: paper \`$tcBatchDvipsPaper' not found in file \`$configPsFile'" >&2; rc=1
822                  fi
823                  ;;
824              esac
825              ;;
826          esac
827          ;;
828        mode)
829          case $2 in
830            "")
831              echo "Usage: $progname dvips mode MODE
832
833Valid MODE settings:"
834              setupModesMfFile
835              listMfModes | sed 's@ .*@@; s@^@  @' | myFmt
836              rc=1
837              ;;
838            *)
839              tcBatchDvipsMode=$2
840              setupTmpDir
841              setupModesMfFile
842              if checkElemInList "$tcBatchDvipsMode" `listMfModes | sed 's@ .*@@'`; then
843                set x `getRes "$tcBatchDvipsMode"`; shift
844                resX=$1; resY=$2
845                fmgrConfigReplace $moreFmgrArgs config.$tcBatchDvipsPrinter '^M' "M $tcBatchDvipsMode"
846                fmgrConfigReplace $moreFmgrArgs config.$tcBatchDvipsPrinter '^D' "D $resX"
847                fmgrConfigReplace $moreFmgrArgs config.$tcBatchDvipsPrinter '^X' "X $resX"
848                fmgrConfigReplace $moreFmgrArgs config.$tcBatchDvipsPrinter '^Y' "Y $resY"
849              else
850                echo "$progname: unknown MODE \`$tcBatchDvipsMode' given as argument for \`$progname dvips mode'" >&2
851                echo "$progname: try \`$progname dvips mode' for help" >&2
852                rc=1
853              fi
854              ;;
855          esac
856          ;;
857        offset)
858          offset=$2
859          case $offset in
860            "")
861              echo "Usage: $progname dvips offset OFFSET"
862              rc=1
863              ;;
864            *)
865              fmgrConfigReplace $moreFmgrArgs config.$tcBatchDvipsPrinter '^O' "O $offset"
866          esac
867          ;;
868        printcmd)
869          printcmd=$2
870          case $printcmd in
871            "")
872              echo "Usage: $progname dvips printcmd CMD"
873              rc=1
874              ;;
875            -)
876              fmgrConfigReplace $moreFmgrArgs config.$tcBatchDvipsPrinter '^o' o
877              ;;
878            *)
879              fmgrConfigReplace $moreFmgrArgs config.$tcBatchDvipsPrinter '^o' "o |$printcmd"
880              ;;
881          esac
882          ;;
883        "")
884          echo "$help" >&2; rc=1
885          ;;
886        *)
887          echo "$progname: unknown option \`$1' given as argument for \`$progname dvips'" >&2
888          echo "$progname: try \`$progname dvips' for help" >&2
889          rc=1
890          ;;
891      esac
892      ;;
893
894    faq)
895      setupTexmfmain
896      if test -f $MT_TEXMFMAIN/doc/tetex/teTeX-FAQ; then
897        <$MT_TEXMFMAIN/doc/tetex/teTeX-FAQ eval ${PAGER-more}
898      else
899        echo "$progname: faq not found (usually in \$TEXMFMAIN/doc/tetex/teTeX-FAQ)" >&2
900        rc=1
901      fi
902      ;;
903
904    findprog)
905      shift
906      ELB_PATH_ONLY=1 echoLocateBinary "$@"
907      ;;
908
909    # handle "texconfig font"
910    font)
911      help="Usage: $progname font vardir DIR
912       $progname font ro
913       $progname font rw
914
915The vardir option changes the VARTEXFONTS variable in the texmf.cnf file.
916
917The rw option makes the VARTEXFONTS directory (and subtrees pk, tfm,
918source) world writable and sets the features appendonlydir:varfonts
919in mktex.cnf.
920
921The ro option makes the VARTEXFONTS directory (and subtrees pk, tfm,
922source) writable for the owner only and sets the feature texmfvar in
923mktex.cnf.
924
925For more information about these \`features', consult the teTeX manual
926(e.g. by running \`texdoc TETEXDOC')."
927
928      case $2 in
929        vardir)
930          case $3 in
931            "")
932              echo "$help" >&2
933              rc=1
934              ;;
935            *)
936              tcBatchFontVardir=$3
937              tfc=`kpsewhich texmf.cnf`
938              if test -n "$tfc"; then
939                if test -w "$tfc"; then
940                  configReplace "$tfc" '^VARTEXFONTS' "VARTEXFONTS  = $tcBatchFontVardir"
941                else
942                  echo "$progname: setting up vardir failed. Reason: no permission to write file \`$tfc'" >&2
943                  rc=1
944                fi
945              else
946                echo "$progname: setting up vardir failed. Reason: failed to find file texmf.cnf" >&2
947                rc=1
948              fi
949              ;;
950          esac
951          ;;
952        rw)
953          MT_VARTEXFONTS=`kpsewhich -var-value VARTEXFONTS`
954          if test -z "$MT_VARTEXFONTS"; then
955            echo "$progname: failed to set \`font rw'; reason: could not determine VARTEXFONTS variable." >&2; rc=1
956            return
957          fi
958          test -d "$MT_VARTEXFONTS" || mktexdir "$MT_VARTEXFONTS"
959          if test ! -d "$MT_VARTEXFONTS"; then
960            echo "$progname: failed to set \`font rw'; reason: directory \`$MT_VARTEXFONTS' does not exist." >&2; rc=1
961            return
962          fi
963          chmod 1777 "$MT_VARTEXFONTS" || {
964            echo "$progname: failed to modify permissions in \`$MT_VARTEXFONTS'." >&2; rc=1
965            return;
966          }
967          (
968            cd "$MT_VARTEXFONTS" || exit
969            echo "$progname: modifying permissions in \`$MT_VARTEXFONTS' ..." >&2
970            for d in pk tfm source; do
971              test -d "$d" && find $d -type d -exec chmod 1777 '{}' \;
972            done
973            echo "$progname: all permissions set." >&2
974          )
975          setupTmpDir
976          fmgrConfigReplace mktex.cnf '^: ..MT_FEATURES=' ": \${MT_FEATURES=appendonlydir:varfonts}"
977          ;;
978        ro)
979          MT_VARTEXFONTS=`kpsewhich -var-value VARTEXFONTS`
980          if test -z "$MT_VARTEXFONTS"; then
981            echo "$progname: failed to set \`font ro'; reason: could not determine VARTEXFONTS variable." >&2; rc=1
982            return
983          fi
984          test -d "$MT_VARTEXFONTS" || mktexdir "$MT_VARTEXFONTS"
985          if test ! -d "$MT_VARTEXFONTS"; then
986            echo "$progname: failed to set \`font ro'; reason: directory \`$MT_VARTEXFONTS' does not exist." >&2; rc=1
987            return
988          fi
989          chmod 755 "$MT_VARTEXFONTS" || {
990            echo "$progname: failed to modify permissions in \`$MT_VARTEXFONTS'." >&2; rc=1
991            return;
992          }
993          (
994            cd "$MT_VARTEXFONTS" || exit
995            echo "$progname: modifying permissions in \`$MT_VARTEXFONTS' ..." >&2
996            for d in pk tfm source; do
997              test -d "$d" && find "$d" -type d -exec chmod 755 '{}' \;
998            done
999            echo "$progname: all permissions set." >&2
1000          )
1001          setupTmpDir
1002          fmgrConfigReplace mktex.cnf '^: ..MT_FEATURES=' ": \${MT_FEATURES=texmfvar}"
1003          ;;
1004        "") echo "$help" >&2; rc=1;;
1005        *) echo "$progname: unknown option \`$2' given as argument for \`$progname font'" >&2
1006           echo "$progname: try \`$progname font' for help" >&2
1007           rc=1
1008           ;;
1009      esac
1010      ;;
1011
1012    formats)
1013      cat >&2 <<EOM
1014texconfig formats is no longer supported, because manual edits of
1015fmtutil.cnf will be overwritten by the new TeX Live package manager,
1016tlmgr, which regenerates that file as needed upon package changes.
1017Thus, to add or remove formats, the recommended method is to use tlmgr
1018to add or remove the appropriate package.
1019
1020If you need to make manual additions, you can edit the file
1021fmtutil-local.cnf under TEXMFLOCAL.  Further information with
1022tlmgr --help and at http://tug.org/texlive/tlmgr.html.
1023
1024Exiting.
1025EOM
1026      exit 1  # but leave the real code for posterity
1027
1028      setupTmpDir
1029      echo "$progname: analyzing old configuration..." >&2
1030      fmtutil --catcfg > $tmpdir/pre
1031      fmtutil --edit
1032      echo "$progname: analyzing new configuration..." >&2
1033      fmtutil --catcfg > $tmpdir/post
1034
1035      if cmp $tmpdir/pre $tmpdir/post >/dev/null 2>&1; then
1036        echo "$progname: no new/updated formats available ..." >&2
1037      else
1038      echo "$progname: updating formats ..." >&2
1039        comm -13 $tmpdir/pre $tmpdir/post > $tmpdir/addOrChange
1040        for i in `awk '{print $1}' $tmpdir/addOrChange`; do
1041          fmtutil --byfmt "$i" || rc=1
1042        done
1043        texlinks --multiplatform || rc=1
1044      fi
1045      ;;
1046
1047    help|--help|-h)
1048      echo "$help"
1049      ;;
1050
1051    # "hyphen FORMAT"
1052    hyphen)
1053      cat >&2 <<EOM
1054texconfig hyphen is no longer supported, because manual edits of
1055language.dat (or language.def) will be overwritten by the new TeX Live
1056package manager, tlmgr, which regenerates those configuration files as
1057needed upon package changes.  Thus, to add or remove hyphenation
1058patterns, the recommended method is to use tlmgr to add or remove the
1059appropriate package.
1060
1061If you need to make manual additions, you can edit the files
1062language-local.dat and language-local.def under TEXMFLOCAL.  Further
1063information with tlmgr --help and at http://tug.org/texlive/tlmgr.html.
1064
1065Exiting.
1066EOM
1067      exit 1  # but leave the real code for posterity
1068
1069      tcBatchHyphenFormat=$2
1070      formatsForHyphen=`getFormatsForHyphen`
1071      formatsForHyphenFmt=`echo "$formatsForHyphen" | myFmt | sed 's@^@  @'`
1072      help="Usage: $progname hyphen FORMAT
1073
1074Valid FORMATs are:
1075$formatsForHyphenFmt"
1076      case $tcBatchHyphenFormat in
1077        "")
1078          echo "$help" >&2; rc=1
1079          ;;
1080        *)
1081          if checkElemInList "$tcBatchHyphenFormat" $formatsForHyphen; then
1082
1083            tcBatchHyphenFile=`fmtutil --showhyphen "$tcBatchHyphenFormat"`
1084            case $tcBatchHyphenFile in
1085              "")
1086                echo "$progname: could not find hyphen setup file for format \`$tcBatchHyphenFormat'" >&2
1087                rc=1
1088                return
1089                ;;
1090            esac
1091
1092            getRelDir "$tcBatchHyphenFile"
1093            case $relPart in
1094              "")
1095                # edit tcBatchHyphenFile directly
1096                tcBatchHFID=
1097                setupTmpDir
1098                tcBatchHFEdit=$tcBatchHyphenFile
1099                tcBatchHFOrig=$tmpdir/hforig
1100                cp "$tcBatchHyphenFile" "$tcBatchHFOrig"
1101                ;;
1102              *)
1103                # use tcfmgr
1104                tcBatchHyphenFileBasename=`echo "$tcBatchHyphenFile" | sed 's@.*/@@'`
1105                setupTmpDir
1106                co=`tcfmgr --tmp $tmpdir --cmd co --file "$tcBatchHyphenFileBasename" --reldir "$relPart" --infile "$tcBatchHyphenFile"`
1107                if test $? != 0; then
1108                  echo "$progname: failed to check out file \`$tcBatchHyphenFile'" >&2
1109                  rc=1
1110                  return 1
1111                else
1112                  set x $co; shift
1113                  tcBatchHFID=$1; tcBatchHFEdit=$3; tcBatchHFOrig=$4
1114                fi
1115                ;;
1116            esac
1117            ${VISUAL-${EDITOR-vi}} "$tcBatchHFEdit"
1118            if cmp "$tcBatchHFEdit" "$tcBatchHFOrig" >/dev/null 2>&1; then
1119              echo "$progname: configuration unchanged." >&2
1120            else
1121              case $tcBatchHFID in
1122                "")
1123                  tcBatchHFOut=$tcBatchHFEdit
1124                  echo "$progname: updated configuration saved as file \`$tcBatchHFOut'" >&2
1125                  lastUpdatedFile=$ci
1126                  ;;
1127                *)
1128                  ci=`tcfmgr --tmp $tmpdir --cmd ci --id "$tcBatchHFID"`
1129                  if test $? != 0; then
1130                    echo "$progname: failed to check in file \`$tcBatchHyphenFileBasename'" >&2
1131                    rc=1
1132                    return
1133                  else
1134                    tcBatchHFOut=$ci
1135                    echo "$progname: updated configuration saved as file \`$tcBatchHFOut'" >&2
1136                    lastUpdatedFile=$ci
1137                  fi
1138                  ;;
1139              esac
1140              fmtutil --byhyphen "$tcBatchHFOut"
1141            fi
1142          else
1143            echo "$progname: invalid format \`$tcBatchHyphenFormat' specified as argument for \`$progname hyphen'" >&2
1144            echo "$progname: for getting help, try \`$progname hyphen'" >&2
1145            rc=1
1146          fi
1147          ;;
1148      esac
1149      ;;
1150
1151    hyphen-list)
1152      getFormatsForHyphen
1153      ;;
1154
1155    init)
1156      case $2 in
1157        "")
1158          if fmtutil --all \
1159             && texlinks --multiplatform \
1160             && updmap; then
1161            :
1162          else
1163            rc=1
1164          fi
1165          ;;
1166        *)
1167          shift 1
1168          for i in "$@"; do
1169            fmtutil --byfmt "$i" || rc=1
1170          done
1171          ;;
1172      esac
1173      ;;
1174
1175    mode-list)
1176      setupModesMfFile
1177      listMfModes
1178      ;;
1179
1180    mode)
1181      case $2 in
1182        "")
1183          echo "Usage: $progname mode MODE
1184
1185Valid MODE settings:"
1186          setupModesMfFile
1187          listMfModes | sed 's@ .*@@; s@^@  @' | myFmt
1188          rc=1
1189          ;;
1190        *)
1191          tcBatchMode=$2
1192          setupModesMfFile
1193          if checkElemInList $tcBatchMode `listMfModes | sed 's@ .*@@'`; then
1194
1195            # modify mktex.cnf
1196            setupTmpDir
1197            fmgrConfigReplace mktex.cnf '^: ..MODE=' ": \${MODE=$tcBatchMode}"
1198            set x `getRes "$tcBatchMode"`; shift
1199            tcBatchRes=$1
1200            fmgrConfigReplace mktex.cnf '^: ..BDPI=' ": \${BDPI=$tcBatchRes}"
1201
1202            if checkForBinary dvips >/dev/null && tcfmgr --cmd find --file config.ps >/dev/null 2>&1; then
1203              tcBatch dvips mode "$tcBatchMode"
1204            fi
1205            if checkForBinary pdftex >/dev/null && tcfmgr --cmd find --file pdftexconfig.tex >/dev/null 2>&1; then
1206              tcBatch pdftex mode "$tcBatchMode"
1207            fi
1208          else
1209            echo "$progname: unknown mode \`$tcBatchMode' specified as argument for \`$progname mode'" >&2; rc=1
1210          fi
1211          ;;
1212      esac
1213      ;;
1214
1215    paper)
1216      help="Usage: $progname paper PAPER
1217
1218Valid PAPER settings:
1219  letter a4"
1220
1221      p=$2; pXdvi=$2; pDvips=$2
1222      case $2 in
1223        letter)
1224          pXdvi=us;;
1225        a4)
1226          pXdvi=a4;;
1227        "") echo "$help" >&2; rc=1; return;;
1228        *)
1229          echo "$progname: unknown PAPER \`$2' given as argument for \`$progname paper'" >&2
1230          echo "$progname: try \`$progname paper' for help" >&2
1231          rc=1
1232          return;;
1233      esac
1234      if checkForBinary dvips >/dev/null && tcfmgr --cmd find --file config.ps >/dev/null 2>&1; then
1235        tcBatch dvips paper $pDvips
1236      fi
1237      if checkForBinary dvipdfm >/dev/null && tcfmgr --cmd find --file config >/dev/null 2>&1; then
1238        tcBatch dvipdfm paper $p
1239      fi
1240      if checkForBinary dvipdfmx >/dev/null && tcfmgr --cmd find --file dvipdfmx.cfg >/dev/null 2>&1; then
1241        tcBatch dvipdfmx paper $p
1242      fi
1243      if checkForBinary xdvi >/dev/null && tcfmgr --cmd find --file XDvi >/dev/null 2>&1; then
1244        tcBatch xdvi paper $pXdvi
1245      fi
1246      if checkForBinary pdftex >/dev/null && tcfmgr --cmd find --file pdftexconfig.tex >/dev/null 2>&1; then
1247        tcBatch pdftex paper $p
1248      fi
1249      ;;
1250
1251    pdftex)
1252      help="Usage: $progname pdftex paper PAPER
1253
1254Valid PAPER settings:
1255  a4 letter"
1256      case $2 in
1257
1258        mode)
1259          case $3 in
1260            "")
1261              echo "Usage: $progname pdftex mode MODE"
1262              rc=1
1263              ;;
1264            *)
1265              tcBatchPdftexMode=$3
1266              setupTmpDir
1267              setupModesMfFile
1268              if checkElemInList "$tcBatchPdftexMode" `listMfModes | sed 's@ .*@@'`; then
1269                set x `getRes "$tcBatchPdftexMode"`; shift
1270                fmgrConfigReplace pdftexconfig.tex 'pdfpkresolution' "\\pdfpkresolution=$1"
1271                if $fmgrConfigReplaceChanged; then
1272                  fmtutil --refresh
1273                fi
1274              else
1275                echo "$progname: unknown MODE \`$tcBatchPdftexMode' given as argument for \`$progname pdftex mode'" >&2
1276                rc=1
1277              fi
1278              ;;
1279          esac
1280          ;;
1281
1282        paper)
1283          case $3 in
1284            letter)
1285              w="8.5 true in"; h="11 true in"
1286              setupTmpDir
1287              fmgrConfigReplace pdftexconfig.tex pdfpagewidth '\pdfpagewidth='"$w"
1288              wChanged=$fmgrConfigReplaceChanged
1289              fmgrConfigReplace pdftexconfig.tex pdfpageheight '\pdfpageheight='"$h"
1290              if $wChanged || $fmgrConfigReplaceChanged; then
1291                fmtutil --refresh
1292              fi
1293              ;;
1294            a4)
1295              w="210 true mm"; h="297 true mm"
1296              fmgrConfigReplace pdftexconfig.tex pdfpagewidth '\pdfpagewidth='"$w"
1297              wChanged=$fmgrConfigReplaceChanged
1298              fmgrConfigReplace pdftexconfig.tex pdfpageheight '\pdfpageheight='"$h"
1299              if $wChanged || $fmgrConfigReplaceChanged; then
1300                fmtutil --refresh
1301              fi
1302              ;;
1303            "") echo "$help" >&2; rc=1;;
1304            *)
1305             echo "$progname: unknown PAPER \`$3' given as argument for \`$progname pdftex paper'" >&2
1306             echo "$progname: try \`$progname pdftex paper' for help" >&2
1307             rc=1 ;;
1308          esac ;;
1309        "")
1310          echo "$help" >&2; rc=1;;
1311        *)
1312          echo "$progname: unknown option \`$2' given as argument for \`$progname pdftex'" >&2
1313          echo "$progname: try \`$progname pdftex' for help" >&2
1314          rc=1
1315          ;;
1316      esac
1317      ;;
1318
1319    rehash)
1320      mktexlsr
1321      ;;
1322
1323    #
1324    version|--version)
1325      echo "$progname version $version"
1326      setupTexmfmain
1327      setupTexmfdist
1328      showDistVersionInfo
1329      (exit 0); exit 0;;
1330
1331    # handle "xdvi paper PAPER"
1332    xdvi)
1333      tcBatchXdviPapers='us           "8.5x11"
1334usr          "11x8.5"
1335legal        "8.5x14"
1336foolscap     "13.5x17.0"
1337a1           "59.4x84.0cm"
1338a2           "42.0x59.4cm"
1339a3           "29.7x42.0cm"
1340a4           "21.0x29.7cm"
1341a5           "14.85x21.0cm"
1342a6           "10.5x14.85cm"
1343a7           "7.42x10.5cm"
1344a1r          "84.0x59.4cm"
1345a2r          "59.4x42.0cm"
1346a3r          "42.0x29.7cm"
1347a4r          "29.7x21.0cm"
1348a5r          "21.0x14.85cm"
1349a6r          "14.85x10.5cm"
1350a7r          "10.5x7.42cm"
1351b1           "70.6x100.0cm"
1352b2           "50.0x70.6cm"
1353b3           "35.3x50.0cm"
1354b4           "25.0x35.3cm"
1355b5           "17.6x25.0cm"
1356b6           "13.5x17.6cm"
1357b7           "8.8x13.5cm"
1358b1r          "100.0x70.6cm"
1359b2r          "70.6x50.0cm"
1360b3r          "50.0x35.3cm"
1361b4r          "35.3x25.0cm"
1362b5r          "25.0x17.6cm"
1363b6r          "17.6x13.5cm"
1364b7r          "13.5x8.8cm"
1365c1           "64.8x91.6cm"
1366c2           "45.8x64.8cm"
1367c3           "32.4x45.8cm"
1368c4           "22.9x32.4cm"
1369c5           "16.2x22.9cm"
1370c6           "11.46x16.2cm"
1371c7           "8.1x11.46cm"
1372c1r          "91.6x64.8cm"
1373c2r          "64.8x45.8cm"
1374c3r          "45.8x32.4cm"
1375c4r          "32.4x22.9cm"
1376c5r          "22.9x16.2cm"
1377c6r          "16.2x11.46cm"
1378c7r          "11.46x8.1cm"'
1379      help="Usage: $progname xdvi paper PAPER
1380
1381Valid PAPER settings:
1382  a1 a1r a2 a2r a3 a3r a4 a4r a5 a5r a6 a6r a7 a7r
1383  b1 b1r b2 b2r b3 b3r b4 b4r b5 b5r b6 b6r b7 b7r
1384  c1 c1r c2 c2r c3 c3r c4 c4r c5 c5r c6 c6r c7 c7r
1385  foolscap legal us usr"
1386      case $2 in
1387        paper-list)
1388          echo "$tcBatchXdviPapers"
1389          ;;
1390        paper)
1391          case $3 in
1392            a1|a1r|a2|a2r|a3|a3r|a4|a4r|a5|a5r|a6|a6r|a7|a7r|b1|b1r|b2|b2r|b3|b3r|b4|b4r|b5|b5r|b6|b6r|b7|b7r|c1|c1r|c2|c2r|c3|c3r|c4|c4r|c5|c5r|c6|c6r|c7|c7r|foolscap|legal|us|usr)
1393              fmgrConfigReplace XDvi paper: "*paper: $3"
1394              ;;
1395            "") echo "$help" >&2; rc=1;;
1396            *)
1397             echo "$progname: unknown PAPER \`$3' given as argument for \`$progname xdvi paper'" >&2
1398             echo "$progname: try \`$progname xdvi paper' for help" >&2
1399             rc=1 ;;
1400          esac ;;
1401        "")
1402          echo "$help" >&2; rc=1;;
1403        *)
1404          echo "$progname: unknown option \`$2' given as argument for \`$progname xdvi'" >&2
1405          echo "$progname: try \`$progname xdvi' for help" >&2
1406          rc=1
1407          ;;
1408      esac
1409      ;;
1410    *)
1411      echo "$progname: unknown option \`$1' given as argument for \`$progname'" >&2
1412      echo "$progname: try \`$progname help' for help" >&2
1413      rc=1
1414  esac
1415}
1416
1417###############################################################################
1418# tcInteractive(void)
1419#   handle interactive mode
1420###############################################################################
1421tcInteractive()
1422{
1423  texconfig-dialog
1424}
1425
1426###############################################################################
1427# main()
1428###############################################################################
1429rc=0
1430case $# in
1431  0) tcInteractive;;
1432  *) tcBatch "$@";;
1433esac
1434
1435cleanup $rc
1436