From 4b886e1937606a539d02dafab04a2f5e399d7ca3 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Wed, 10 Jan 2007 11:18:00 +0100 Subject: stable 2007.01.10 11:18 --- scripts/context/ruby/base/switch.rb | 19 ++++++++++++++++++- scripts/context/ruby/base/tex.rb | 6 +++++- scripts/context/ruby/texexec.rb | 33 +++++++++++++++++---------------- scripts/context/ruby/texmfstart.rb | 29 +++++++++++++++++++++++------ 4 files changed, 63 insertions(+), 24 deletions(-) (limited to 'scripts') diff --git a/scripts/context/ruby/base/switch.rb b/scripts/context/ruby/base/switch.rb index 5187a795f..19eced424 100644 --- a/scripts/context/ruby/base/switch.rb +++ b/scripts/context/ruby/base/switch.rb @@ -86,7 +86,7 @@ module CommandBase def initialize(commandline,logger,banner) @commandline, @logger, @banner = commandline, logger, banner - @forcenewline, @versiondone = false, false + @forcenewline, @versiondone, @error = false, false, false version if @commandline.option('version') end @@ -117,6 +117,23 @@ module CommandBase initlogger ; @logger.report(str) end + def seterror + @error = true + end + + def error? + return @error + end + + def exit + if @error then Kernel.exit(1) else Kernel.exit(0) end + end + + def execute(str=nil) + send(str || action || 'main') + exit + end + def debug(*str) initlogger ; @logger.debug(str) end diff --git a/scripts/context/ruby/base/tex.rb b/scripts/context/ruby/base/tex.rb index 69d5fd750..5674157b5 100644 --- a/scripts/context/ruby/base/tex.rb +++ b/scripts/context/ruby/base/tex.rb @@ -634,6 +634,7 @@ class TEX # generate tex formats unless texformats || mpsformats then report('provide valid format (name.tex, name.mp, ...) or format id (metafun, en, nl, ...)') + setvariable('error','no format specified') end if texformats && texengine then report("using tex engine #{texengine}") @@ -677,11 +678,14 @@ class TEX mpsformats.each do |mpsformat| report("generating mps format #{mpsformat}") progname = validprogname([getvariable('progname'),mpsformat,mpsengine]) - runcommand([quoted(mpsengine),prognameflag(progname),iniflag,tcxflag,runoptions(mpsengine),mpsformat,mpsmakeextras(mpsformat)]) + if not runcommand([quoted(mpsengine),prognameflag(progname),iniflag,tcxflag,runoptions(mpsengine),mpsformat,mpsmakeextras(mpsformat)]) then + setvariable('error','no format made') + end end else report("unable to make format due to lack of permissions") mpsformatpath = '' + setvariable('error','file permission problem') end else mpsformatpath = '' diff --git a/scripts/context/ruby/texexec.rb b/scripts/context/ruby/texexec.rb index 3d504ac9e..992766c05 100644 --- a/scripts/context/ruby/texexec.rb +++ b/scripts/context/ruby/texexec.rb @@ -36,6 +36,7 @@ class Commands end job.makeformats job.inspect && Kpse.inspect if @commandline.option('verbose') + seterror if job.error? end end @@ -60,7 +61,7 @@ class Commands prepare(job) job.processtex job.inspect && Kpse.inspect if @commandline.option('verbose') - exit 1 if job.error? + seterror if job.error? end end @@ -70,7 +71,7 @@ class Commands prepare(job) job.processmptex job.inspect && Kpse.inspect if @commandline.option('verbose') - exit 1 if job.error? + seterror if job.error? end end @@ -80,7 +81,7 @@ class Commands prepare(job) job.processmpxtex job.inspect && Kpse.inspect if @commandline.option('verbose') - exit 1 if job.error? + seterror if job.error? end end @@ -90,7 +91,7 @@ class Commands prepare(job) job.processmpgraphic job.inspect && Kpse.inspect if @commandline.option('verbose') - exit 1 if job.error? + seterror if job.error? end end @@ -100,7 +101,7 @@ class Commands prepare(job) job.processmpstatic job.inspect && Kpse.inspect if @commandline.option('verbose') - exit 1 if job.error? + seterror if job.error? end end @@ -216,11 +217,11 @@ class Commands fnames.each do |ffname| if msuffixes.include?(File.splitname(ffname)[1]) && FileTest.file?(ffname) then if mod = File.open(job.tempfilename('tex'),'w') then -if File.suffix(ffname) =~ /^(mkii|mkiv)$/o then - markfile = $1 -else - markfile = nil -end + if File.suffix(ffname) =~ /^(mkii|mkiv)$/o then + markfile = $1 + else + markfile = nil + end Kpse.runscript('ctxtools',ffname,'--document') if ted = File.silentopen(File.suffixed(ffname,'ted')) then firstline = ted.gets @@ -244,11 +245,11 @@ end job.setvariable('simplerun',true) # job.setvariable('nooptionfile',true) job.setvariable('files',[job.tempfilename]) -result = File.unsuffixed(File.basename(ffname)) -if markfile then - result = result+'-'+markfile -end -job.setvariable('result',result) + result = File.unsuffixed(File.basename(ffname)) + if markfile then + result = result+'-'+markfile + end + job.setvariable('result',result) job.processtex # ["dvi", "pdf","ps"].each do |s| # File.silentrename(job.tempfilename(s),File.suffixed(ffname,s)); @@ -767,4 +768,4 @@ commandline.registerflag('verbose') commandline.expand -Commands.new(commandline,logger,banner).send(commandline.action || 'main') +Commands.new(commandline,logger,banner).execute(commandline.action || 'main') # or just execute() diff --git a/scripts/context/ruby/texmfstart.rb b/scripts/context/ruby/texmfstart.rb index 6dd79dc1e..9a19995a1 100644 --- a/scripts/context/ruby/texmfstart.rb +++ b/scripts/context/ruby/texmfstart.rb @@ -2490,27 +2490,35 @@ def execute(arguments) if $selfmerge then output("ruby libraries are cleaned up") if SelfMerge::cleanup output("ruby libraries are merged") if SelfMerge::merge + return true elsif $selfcleanup then output("ruby libraries are cleaned up") if SelfMerge::cleanup + return true elsif $serve then if ENV['KPSEMETHOD'] && ENV['KPSEPORT'] then # # kpse_merge_done: require 'base/kpseremote' begin KpseRemote::start_server rescue + return false + else + return true end else usage puts("") puts("message : set 'KPSEMETHOD' and 'KPSEPORT' variables") + return false end elsif $help || ! $filename || $filename.empty? then usage loadtree($tree) loadenvironment($environment) show_environment() + return true elsif $batch && $filename && ! $filename.empty? then # todo, take commands from file and avoid multiple starts and checks + return false else report("texmfstart version #{$version}") loadtree($tree) @@ -2531,33 +2539,42 @@ def execute(arguments) make(filename,$mswindows,!$mswindows,$remove) end end + return true # guess elsif $browser && $filename =~ /^http\:\/\// then - launch($filename) + return launch($filename) else begin process do if $direct || $filename =~ /^bin\:/ then - direct($filename) + return direct($filename) elsif $edit && ! $editor.empty? then - edit($filename) + return edit($filename) else # script: or no prefix command = find(shortpathname($filename),$program) if command then register("THREAD",File.dirname(File.expand_path(command))) - run(command) + return run(command) else report('unable to locate program') + return false end end end rescue report('fatal error in starting process') + return false end end end end -execute(ARGV) +if execute(ARGV) then + report("\nexecution was successful") if $verbose + exit(1) +else + report("\nexecution failed") if $verbose + exit(0) +end -exit (if ($?.to_i rescue 0) > 0 then 1 else 0 end) +# exit (if ($?.to_i rescue 0) > 0 then 1 else 0 end) -- cgit v1.2.3