diff options
-rwxr-xr-x | Master/texmf/scripts/texlive/texdoc.tlu | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/Master/texmf/scripts/texlive/texdoc.tlu b/Master/texmf/scripts/texlive/texdoc.tlu index d7a3e655cd5..c01943599a1 100755 --- a/Master/texmf/scripts/texlive/texdoc.tlu +++ b/Master/texmf/scripts/texlive/texdoc.tlu @@ -21,15 +21,16 @@ Public domain.]] progname = 'texdoc' version = '0.31' usage_msg = [[ -Usage: texdoc -h, --help | -v, --version | [option] name +Usage: texdoc -h, --help | -v, --version | [option] name(s) -h|--help Show this help. -V|--version Print the version of the program. -v|--verbose Show the command being used to display the documentation. -l|--list List matching files, do not start a viewer. -s|--search Search for name as a pattern.]] notfound_msg = [[ -Sorry, I'm not smart enough to find documentation for PKGNAME. Please see -http://tug.org/pkginfo/PKGNAME for information about the package.]] +Sorry, no documentation found for PKGNAME. +Please try texdoc -s PKGNAME or even texdoc -S PKGNAME +or search the TeX Catalogue at http://ctan.org/search.html#byDescription.]] place_holder = '%%s' -- used for viewer commands --[[ zip/gz support ]] @@ -52,10 +53,16 @@ function print_debug (message) end end +-- [[ exit codes ]] +-- 0 OK +-- 1 Usage +-- 2 No doc found for at least one arg +-- ? Should do something for viewer problems etc + -- must have at least one arg if not arg[1] then print (usage_msg) - return + os.exit(1) end -- reading and setting options @@ -78,6 +85,12 @@ while table.maxn(arg) > 0 and string.match(arg[1],'^%-') do end end +-- must have at least one arg left after eating up the options +if not arg[1] then + print (usage_msg) + os.exit(1) +end + --[[ function definitions ]] function list_iter (t) local i = 0 @@ -483,6 +496,7 @@ function try_viewing () end -- [[ the main loop ]] +exit_code = 0 for docname in list_iter (arg) do if alias[docname] then print ("texdoc info: "..docname.." aliased to "..alias[docname]) @@ -508,13 +522,14 @@ for docname in list_iter (arg) do end -- found a filename with that extension or not? end -- for ext end -- if construct "case mode in" - if not docfound then -- apologize if we didn't suceed + if not docfound then -- apologize if we didn't succeed + exit_code = 2 msg = string.gsub(notfound_msg, 'PKGNAME', docname) print (msg) -- to get rid of gsub's 2nd value end end -- for docname in arg --- cleanup_tmpdir() +os.exit(exit_code) -- Local Variables: -- lua-indent-level: 4 |