diff options
author | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2008-07-13 14:54:25 +0000 |
---|---|---|
committer | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2008-07-13 14:54:25 +0000 |
commit | 8192d858f1582088988f0b8b489f619506508ee5 (patch) | |
tree | c9b5e19dba40e6221ff478308c4df86df03b2e51 /Master/texmf | |
parent | 7c0e291115ae917d285c512ae17f1cea685b7977 (diff) |
don't use system-dependant rm_file and rm_dir. May not be a good idea, see post on the list
git-svn-id: svn://tug.org/texlive/trunk@9513 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf')
-rwxr-xr-x | Master/texmf/scripts/texlive/texdoc.tlu | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/Master/texmf/scripts/texlive/texdoc.tlu b/Master/texmf/scripts/texlive/texdoc.tlu index 8fbe82e77c7..c4619dad416 100755 --- a/Master/texmf/scripts/texlive/texdoc.tlu +++ b/Master/texmf/scripts/texlive/texdoc.tlu @@ -30,6 +30,7 @@ Usage: texdoc -h, --help | -v, --version | [option] name 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.]] +place_holder = '%%s' -- used for viewer commands -- [[ for our eyes only ]] opt_debug = false @@ -306,8 +307,6 @@ if (os.type == "windows") then set_config_list { unzip_gz = "gzip -d -c ", unzip_bz2 = "bzip2 -d -c ", - rm_file = 'del /F ', - rm_dir = 'rmdir ', viewer_dvi = '(start /wait %s) &', viewer_html = '(start /wait %s) &', viewer_pdf = '(start /wait %s) &', @@ -319,8 +318,6 @@ else -- since we don't support msdos, if os.type is not windows, it's unix set_config_list { unzip_gz = "gzip -d -c ", unzip_bz2 = "bzip2 -d -c ", - rm_file = 'rm -f ', - rm_dir = 'rmdir ' } if (os.name == 'macosx') then set_config_list { @@ -400,8 +397,8 @@ function unzip_if_needed (ext) if zipext then unzip_command = config['unzip_'..zipext] viewext = string.match(ext,'%.(.*)%..*$') - basebame_pattern = '.*/(.*%.' .. viewext .. ')' - basename = string.match(filename,basebame_pattern) + basename_pattern = '.*/(.*%.' .. viewext .. ')' + basename = string.match(filename,basename_pattern) -- uncompress only once per file, in case it is given -- more than once (dvi besides ps or so) -- TODO: to be done @@ -409,12 +406,13 @@ function unzip_if_needed (ext) unzip_commandline = unzip_command .. filename .. " > " .. tmpdir .. "/" .. basename if os.execute(unzip_commandline) then + os.execute ("ls "..tmpdir) + print ("unzipped to tmpdir") filename = tmpdir .. "/" .. basename else print("Error executing \n" .. unzip_commandline) end - viewer_replacement = filename .. ';' .. config.rm_file - .. filename .. ';' .. config.rm_dir .. tmpdir + -- shall_cleanup = true else if ext == '' then -- fallback if complete filename has been specified @@ -424,7 +422,6 @@ function unzip_if_needed (ext) ext = 'txt' end end - viewer_replacement = filename viewext = string.match(ext,'%.(.*)$') if not viewext or not config['viewer_'..viewext] then -- complete filename specified, unknown extension, use "txt" @@ -436,27 +433,30 @@ end -- view a file, if possible function try_viewing () if config['viewer_'..viewext] == nil then - print ("Sorry, no "..viewext.."viewer found. You can choose one\n".. + print ("Sorry, no "..viewext.." viewer found. You can choose one\n".. "with the viewer_"..viewext" variable in texdoc.cnf.\n".. "Please report the problem so we can add your viewer as a default.\n") else - if string.match (view_command, '%%s') then + view_command = config['viewer_'..viewext] + if string.match (view_command, place_holder) then view_command = string.gsub( - config['viewer_'..viewext], '%%s',viewer_replacement) + view_command, place_holder, '"'..filename..'"') else - view_command = view_command..' '..viewer_replacement + view_command = view_command..' "'..filename..'"' end if verbose then print(view_command) end view_result = os.execute(view_command) - if view_result then - return true - else + if not view_result then print("Error executing \n" .. view_command) end end - return false + if shall_cleanup then + os.remove (filename) + os.remove (tmpdir) + end + return view_result end -- [[ the main loop ]] @@ -474,6 +474,7 @@ for docname in list_iter (arg) do if string.match (mode, 'list') then print(filename) else -- mode is view, is unzipping needed? + local tmpdir, filename, viewext, shall_cleanup unzip_if_needed(ext) local ok = try_viewing() if ok then break end |