lib/rbbt/util/cmd.rb in rbbt-util-5.30.10 vs lib/rbbt/util/cmd.rb in rbbt-util-5.30.11

- old
+ new

@@ -99,10 +99,11 @@ log = options.delete(:log) no_fail = options.delete(:no_fail) no_fail = options.delete(:nofail) if no_fail.nil? no_wait = options.delete(:no_wait) xvfb = options.delete(:xvfb) + bar = options.delete(:progress_bar) dont_close_in = options.delete(:dont_close_in) log = true if log.nil? @@ -181,10 +182,11 @@ ConcurrentStream.setup sout, :pids => pids, :autojoin => no_wait, :no_fail => no_fail err_thread = Thread.new do while line = serr.gets + bar.process(line) if bar sout.log = line Log.log "STDERR [#{pid}]: " + line, stderr end if Integer === stderr and log serr.close end @@ -218,10 +220,12 @@ end def self.cmd_pid(*args) all_args = *args + bar = all_args.last[:progress_bar] if Hash === all_args.last + all_args << {} unless Hash === all_args.last level = all_args.last[:log] || 0 level = 0 if TrueClass === level level = 10 if FalseClass === level @@ -231,20 +235,30 @@ all_args.last[:pipe] = true io = cmd(*all_args) pid = io.pids.first + line = "" if bar while c = io.getc STDERR << c if Log.severity <= level + line << c if bar if c == "\n" + bar.process(line) if bar if pid Log.logn "STDOUT [#{pid}]: ", level else Log.logn "STDOUT: ", level end + line = "" if bar end end - io.join + begin + io.join + bar.remove if bar + rescue + bar.remove(true) if bar + raise $! + end nil end def self.cmd_log(*args)