summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-02-02 22:44:20 +0000
committerKarl Berry <karl@freefriends.org>2020-02-02 22:44:20 +0000
commit57bf353019ba7087c6b8ab64205abb88139ba4c4 (patch)
treefd5d11df7c68334269283b00e29494e307a7b525 /Build
parent698edf65b4e683cfffd9f8d442edd59683f48d1f (diff)
texdoc (2feb20)
git-svn-id: svn://tug.org/texlive/trunk@53643 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rwxr-xr-xBuild/source/texk/texlive/linked_scripts/texdoc/texdoc.tlu34
1 files changed, 31 insertions, 3 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/texdoc/texdoc.tlu b/Build/source/texk/texlive/linked_scripts/texdoc/texdoc.tlu
index b8598682364..bc2139435a3 100755
--- a/Build/source/texk/texlive/linked_scripts/texdoc/texdoc.tlu
+++ b/Build/source/texk/texlive/linked_scripts/texdoc/texdoc.tlu
@@ -7,11 +7,39 @@
-- Note: we keep this file small as much as possible so that make it easier
-- to install a new version of texdoc in TEXMFHOME.
--- setup the kpse library and load texdoclib
+local lfs = require 'lfs'
+local kpse = require 'kpse'
+
+-- setup kpse library
kpse.set_program_name(arg[-1], 'texdoc')
-local texdoc = require('texdoclib')
--- execute
+-- get realpath of this file
+local function realpath(p)
+ if os.type == 'unix' then
+ local h = io.popen(string.format("realpath '%s'", p))
+ local r = h:read('*a')
+ h:close()
+ return r:gsub('\n$', '')
+ else
+ return ''
+ end
+end
+local file = realpath(arg[0])
+
+-- if the file is not in TEXMFMAIN, set temporal TEXMFAUXTREES and TEXMFDIST
+local texmf = file:match('^(.*/texmf[^/]*)/scripts/texdoc/texdoc.tlu$')
+if texmf ~= nil then
+ if texmf ~= kpse.var_value('TEXMFMAIN') then
+ io.stderr:write('Info: ' ..
+ 'Running Texdoc not installed in the current TEXMFMAIN.\n')
+ os.setenv('TEXMFAUXTREES', texmf .. ',')
+ os.setenv('TEXMFDIST', ',')
+ end
+end
+
+-- load the library and execute
+local texdoc = require 'texdoclib'
+assert(texdoc.cli, 'Internal error: Texdoc is not installed properly.')
texdoc.cli.exec()
-- vim: ft=lua: