/usr/bin/xdvi is in texlive-binaries 2017.20170613.44572-8build1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | #! /usr/bin/perl -w
# This is the xdvi wrapper script for Debian, based on Thomas Esser's
# teTeX version 0.2.
# Debian version: Copyright Julian Gilbey, 2002. Lots of modifications
# by Chung-chieh Shan <ken@digitas.harvard.edu>.
# Also by TSUCHIYA Masatoshi <tsuchiya@pine.kuee.kyoto-u.ac.jp>.
# Original version: Copyright Thomas Esser, 1998.
# Permission to distribute this software is given under the terms of
# the GNU general public license version 2 or later.
# Thomas writes:
# This script sets some environment variables to make sure that xdvi's
# resource file in $XDVIINPUTS/xdvi is read by xdvi.bin.
# Special care was taken to make this work for old R3, too. Therefore,
# we need to modify XAPPLRESDIR. If you are running R4 or later, you
# can set XUSERFILESEARCHPATH for user specific application default
# files. You cannot use XAPPLRESDIR for user specific application default
# files.
# Julian writes:
# This has been rewritten in Perl so that we can mangle the arguments
# to handled gzipped dvi files, which not have errors if there are
# spaces in some arguments. XAPPLRESDIR is no longer modified.
# Stephen Gildea writes:
# Debian distributes X11R6, therefore this script should not clobber
# XAPPLRESDIR, which is for user customizations.
use strict;
use FileHandle;
use File::Basename;
use File::Spec;
use File::Temp qw/ tempfile /;
my @NAMEOPT;
if (@ARGV == 1 and ($ARGV[0] eq '-help' or $ARGV[0] eq '-version')) {
@NAMEOPT=();
} else {
@NAMEOPT=qw(-name xdvi);
}
$ENV{'XDVIINPUTS'} .= ":\$TEXMF/{xdvi,web2c}";
my ($xdviappfile, $xdviappdir, $xdviapppath);
$xdviappfile=`kpsewhich -progname=xdvi --format='other text files' XDvi`;
if ("$xdviappfile" ne '') {
$xdviappdir=dirname($xdviappfile);
$xdviapppath="$xdviappdir/%N";
if (exists $ENV{'XFILESEARCHPATH'}) {
$ENV{'XFILESEARCHPATH'} = "$xdviapppath:$ENV{'XFILESEARCHPATH'}";
} else {
$ENV{'XFILESEARCHPATH'} = "$xdviapppath:%D";
}
}
my $status;
if (@ARGV) {
my $filename = pop @ARGV;
if ($filename =~ /\.(gz|Z|bz2)$/) {
my @command = $1 eq 'bz2' ? qw(bzip2 -d -c) : qw(gzip -d -c);
require Fcntl;
my $fh = tempfile( UNLINK => 1 )
or die "xdvi: cannot create temporary file: $!\n";
fcntl $fh, Fcntl::F_SETFD(), 0
or die "xdvi: disabling close-on-exec for temporary file: $!\n";
if (my $child = fork) {
1 while wait != $child;
if ($? & 255) {
die "xdvi: $command[0] terminated abnormally: $?\n";
} elsif ($?) {
my $code = $? >> 8;
die "xdvi: $command[0] terminated with exit code $code\n";
}
} elsif (defined $child) {
STDOUT->fdopen( $fh, "w" );
exec @command, $filename;
} else {
die "xdvi: fork: $!\n";
}
$status = system('xdvi.bin', @NAMEOPT, @ARGV, '/dev/fd/'.fileno($fh));
} else {
$status = system('xdvi.bin', @NAMEOPT, @ARGV, $filename);
}
} else {
$status = system('xdvi.bin', @NAMEOPT);
}
if ($status & 255) {
die "xdvi: xdvi.bin terminated abnormally: $?\n";
} else {
my $code = $? >> 8;
exit $code;
}
|