diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-05-19 00:07:25 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-05-19 00:07:25 +0000 |
commit | d371e3583e3b1e0692f92343017b62d2628190ff (patch) | |
tree | be82924ada754f8542f394d0a3d28e0a0b02a098 /lib/shell | |
parent | 1fae66fca28167ca0e25625091c5df49405b8023 (diff) | |
download | ruby-d371e3583e3b1e0692f92343017b62d2628190ff.tar.gz |
* lib: revert r31635-r31638 and untabify with expand(1).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/shell')
-rw-r--r-- | lib/shell/builtin-command.rb | 32 | ||||
-rw-r--r-- | lib/shell/command-processor.rb | 200 | ||||
-rw-r--r-- | lib/shell/error.rb | 6 | ||||
-rw-r--r-- | lib/shell/filter.rb | 10 | ||||
-rw-r--r-- | lib/shell/process-controller.rb | 40 | ||||
-rw-r--r-- | lib/shell/system-command.rb | 12 | ||||
-rw-r--r-- | lib/shell/version.rb | 6 |
7 files changed, 153 insertions, 153 deletions
diff --git a/lib/shell/builtin-command.rb b/lib/shell/builtin-command.rb index f0e064e435..b1ca5c38f6 100644 --- a/lib/shell/builtin-command.rb +++ b/lib/shell/builtin-command.rb @@ -1,8 +1,8 @@ # # shell/builtin-command.rb - -# $Release Version: 0.7 $ -# $Revision$ -# by Keiju ISHITSUKA(keiju@ruby-lang.org) +# $Release Version: 0.7 $ +# $Revision$ +# by Keiju ISHITSUKA(keiju@ruby-lang.org) # # -- # @@ -83,19 +83,19 @@ class Shell end end - # class Sort < Cat - # def initialize(sh, *filenames) - # super - # end - # - # def each(rs = nil) - # ary = [] - # super{|l| ary.push l} - # for l in ary.sort! - # yield l - # end - # end - # end +# class Sort < Cat +# def initialize(sh, *filenames) +# super +# end +# +# def each(rs = nil) +# ary = [] +# super{|l| ary.push l} +# for l in ary.sort! +# yield l +# end +# end +# end class AppendIO < BuiltInCommand def initialize(sh, io, filter) diff --git a/lib/shell/command-processor.rb b/lib/shell/command-processor.rb index d7a48232cb..ae157eba5c 100644 --- a/lib/shell/command-processor.rb +++ b/lib/shell/command-processor.rb @@ -1,8 +1,8 @@ # # shell/command-controller.rb - -# $Release Version: 0.7 $ -# $Revision$ -# by Keiju ISHITSUKA(keiju@ruby-lang.org) +# $Release Version: 0.7 $ +# $Revision$ +# by Keiju ISHITSUKA(keiju@ruby-lang.org) # # -- # @@ -19,7 +19,7 @@ require "shell/builtin-command" class Shell class CommandProcessor - # include Error +# include Error # # initialize of Shell and related classes. @@ -68,9 +68,9 @@ class Shell # # CommandProcessor#expand_path(path) - # path: String - # return: String - # returns the absolute path for <path> + # path: String + # return: String + # returns the absolute path for <path> # def expand_path(path) @shell.expand_path(path) @@ -86,13 +86,13 @@ class Shell # - # # CommandProcessor#foreach(path, rs) - # path: String - # rs: String - record separator - # iterator - # Same as: - # File#foreach (when path is file) - # Dir#foreach (when path is directory) - # path is relative to pwd + # path: String + # rs: String - record separator + # iterator + # Same as: + # File#foreach (when path is file) + # Dir#foreach (when path is directory) + # path is relative to pwd # def foreach(path = nil, *rs) path = "." unless path @@ -107,13 +107,13 @@ class Shell # # CommandProcessor#open(path, mode) - # path: String - # mode: String - # return: File or Dir - # Same as: - # File#open (when path is file) - # Dir#open (when path is directory) - # mode has an effect only when path is a file + # path: String + # mode: String + # return: File or Dir + # Same as: + # File#open (when path is file) + # Dir#open (when path is directory) + # mode has an effect only when path is a file # def open(path, mode = nil, perm = 0666, &b) path = expand_path(path) @@ -136,9 +136,9 @@ class Shell # # CommandProcessor#unlink(path) - # same as: - # Dir#unlink (when path is directory) - # File#unlink (when path is file) + # same as: + # Dir#unlink (when path is directory) + # File#unlink (when path is file) # def unlink(path) @shell.check_point @@ -155,19 +155,19 @@ class Shell # # CommandProcessor#test(command, file1, file2) # CommandProcessor#[command, file1, file2] - # command: char or String or Symbol - # file1: String - # file2: String(optional) - # return: Boolean - # same as: - # test() (when command is char or length 1 string or symbol) - # FileTest.command (others) - # example: - # sh[?e, "foo"] - # sh[:e, "foo"] - # sh["e", "foo"] - # sh[:exists?, "foo"] - # sh["exists?", "foo"] + # command: char or String or Symbol + # file1: String + # file2: String(optional) + # return: Boolean + # same as: + # test() (when command is char or length 1 string or symbol) + # FileTest.command (others) + # example: + # sh[?e, "foo"] + # sh[:e, "foo"] + # sh["e", "foo"] + # sh[:exists?, "foo"] + # sh["exists?", "foo"] # alias top_level_test test def test(command, file1, file2=nil) @@ -209,8 +209,8 @@ class Shell #-- # # CommandProcessor#mkdir(*path) - # path: String - # same as Dir.mkdir() + # path: String + # same as Dir.mkdir() # def mkdir(*path) @shell.check_point @@ -234,8 +234,8 @@ class Shell # # CommandProcessor#rmdir(*path) - # path: String - # same as Dir.rmdir() + # path: String + # same as Dir.rmdir() # def rmdir(*path) @shell.check_point @@ -249,13 +249,13 @@ class Shell # # CommandProcessor#system(command, *opts) - # command: String - # opts: String - # return: SystemCommand - # Same as system() function - # example: - # print sh.system("ls", "-l") - # sh.system("ls", "-l") | sh.head > STDOUT + # command: String + # opts: String + # return: SystemCommand + # Same as system() function + # example: + # print sh.system("ls", "-l") + # sh.system("ls", "-l") | sh.head > STDOUT # def system(command, *opts) if opts.empty? @@ -270,7 +270,7 @@ class Shell # # ProcessCommand#rehash - # clear command hash table. + # clear command hash table. # def rehash @system_commands = {} @@ -373,21 +373,21 @@ class Shell # # CommandProcessor.def_system_command(command, path) - # command: String - # path: String - # define 'command()' method as method. + # command: String + # path: String + # define 'command()' method as method. # def self.def_system_command(command, path = command) begin eval((d = %Q[def #{command}(*opts) - SystemCommand.new(@shell, '#{path}', *opts) + SystemCommand.new(@shell, '#{path}', *opts) end]), nil, __FILE__, __LINE__ - 1) rescue SyntaxError Shell.notify "warn: Can't define #{command} path: #{path}." end Shell.notify "Define #{command} path: #{path}.", Shell.debug? Shell.notify("Definition of #{command}: ", d, - Shell.debug.kind_of?(Integer) && Shell.debug > 1) + Shell.debug.kind_of?(Integer) && Shell.debug > 1) end def self.undef_system_command(command) @@ -417,11 +417,11 @@ class Shell eval((d = %Q[def #{ali}(*opts) @shell.__send__(:#{command}, *(CommandProcessor.alias_map[:#{ali}].call *opts)) - end]), nil, __FILE__, __LINE__ - 1) + end]), nil, __FILE__, __LINE__ - 1) else - args = opts.collect{|opt| '"' + opt + '"'}.join(",") - eval((d = %Q[def #{ali}(*opts) + args = opts.collect{|opt| '"' + opt + '"'}.join(",") + eval((d = %Q[def #{ali}(*opts) @shell.__send__(:#{command}, #{args}, *opts) end]), nil, __FILE__, __LINE__ - 1) end @@ -432,7 +432,7 @@ class Shell end Shell.notify "Define #{ali} command: #{command}.", Shell.debug? Shell.notify("Definition of #{ali}: ", d, - Shell.debug.kind_of?(Integer) && Shell.debug > 1) + Shell.debug.kind_of?(Integer) && Shell.debug > 1) self end @@ -444,14 +444,14 @@ class Shell # # CommandProcessor.def_builtin_commands(delegation_class, command_specs) - # delegation_class: Class or Module - # command_specs: [[command_name, [argument,...]],...] - # command_name: String - # arguments: String - # FILENAME?? -> expand_path(filename??) - # *FILENAME?? -> filename??.collect{|f|expand_path(f)}.join(", ") - # define command_name(argument,...) as - # delegation_class.command_name(argument,...) + # delegation_class: Class or Module + # command_specs: [[command_name, [argument,...]],...] + # command_name: String + # arguments: String + # FILENAME?? -> expand_path(filename??) + # *FILENAME?? -> filename??.collect{|f|expand_path(f)}.join(", ") + # define command_name(argument,...) as + # delegation_class.command_name(argument,...) # def self.def_builtin_commands(delegation_class, command_specs) for meth, args in command_specs @@ -469,18 +469,18 @@ class Shell end }.join(", ") d = %Q[def #{meth}(#{arg_str}) - #{delegation_class}.#{meth}(#{call_arg_str}) - end] - Shell.notify "Define #{meth}(#{arg_str})", Shell.debug? - Shell.notify("Definition of #{meth}: ", d, - Shell.debug.kind_of?(Integer) && Shell.debug > 1) - eval d + #{delegation_class}.#{meth}(#{call_arg_str}) + end] + Shell.notify "Define #{meth}(#{arg_str})", Shell.debug? + Shell.notify("Definition of #{meth}: ", d, + Shell.debug.kind_of?(Integer) && Shell.debug > 1) + eval d end end # # CommandProcessor.install_system_commands(pre) - # pre: String - command name prefix + # pre: String - command name prefix # defines every command which belongs in default_system_path via # CommandProcessor.command(). It doesn't define already defined # methods twice. By default, "pre_" is prefixes to each method @@ -526,29 +526,29 @@ class Shell end Shell.notify "method added: Shell##{name}.", Shell.debug? Shell.module_eval(%Q[def #{name}(*args, &block) - begin - @command_processor.__send__(:#{name}, *args, &block) - rescue Exception - $@.delete_if{|s| /:in `__getobj__'$/ =~ s} #` - $@.delete_if{|s| /^\\(eval\\):/ =~ s} - raise - end + begin + @command_processor.__send__(:#{name}, *args, &block) + rescue Exception + $@.delete_if{|s| /:in `__getobj__'$/ =~ s} #` + $@.delete_if{|s| /^\\(eval\\):/ =~ s} + raise + end end], __FILE__, __LINE__) - if Shell::Filter.method_defined?(id) - Shell.notify "warn: override definition of Shell::Filter##{name}." - Shell.notify "warn: alias Shell##{name} to Shell::Filter##{name}_org." - Filter.module_eval "alias #{name}_org #{name}" - end - Shell.notify "method added: Shell::Filter##{name}.", Shell.debug? - Filter.module_eval(%Q[def #{name}(*args, &block) - begin - self | @shell.__send__(:#{name}, *args, &block) - rescue Exception - $@.delete_if{|s| /:in `__getobj__'$/ =~ s} #` - $@.delete_if{|s| /^\\(eval\\):/ =~ s} - raise - end + if Shell::Filter.method_defined?(id) + Shell.notify "warn: override definition of Shell::Filter##{name}." + Shell.notify "warn: alias Shell##{name} to Shell::Filter##{name}_org." + Filter.module_eval "alias #{name}_org #{name}" + end + Shell.notify "method added: Shell::Filter##{name}.", Shell.debug? + Filter.module_eval(%Q[def #{name}(*args, &block) + begin + self | @shell.__send__(:#{name}, *args, &block) + rescue Exception + $@.delete_if{|s| /:in `__getobj__'$/ =~ s} #` + $@.delete_if{|s| /^\\(eval\\):/ =~ s} + raise + end end], __FILE__, __LINE__) end @@ -557,7 +557,7 @@ class Shell # def self.install_builtin_commands # method related File. - # (exclude open/foreach/unlink) + # (exclude open/foreach/unlink) normal_delegation_file_methods = [ ["atime", ["FILENAME"]], ["basename", ["fn", "*opts"]], @@ -580,12 +580,12 @@ class Shell ["truncate", ["FILENAME", "length"]], ["utime", ["atime", "mtime", "*FILENAMES"]]] - def_builtin_commands(File, normal_delegation_file_methods) - alias_method :rm, :delete + def_builtin_commands(File, normal_delegation_file_methods) + alias_method :rm, :delete - # method related FileTest - def_builtin_commands(FileTest, - FileTest.singleton_methods(false).collect{|m| [m, ["FILENAME"]]}) + # method related FileTest + def_builtin_commands(FileTest, + FileTest.singleton_methods(false).collect{|m| [m, ["FILENAME"]]}) end diff --git a/lib/shell/error.rb b/lib/shell/error.rb index 8c37d2ab5e..2701338b5a 100644 --- a/lib/shell/error.rb +++ b/lib/shell/error.rb @@ -1,8 +1,8 @@ # # shell/error.rb - -# $Release Version: 0.7 $ -# $Revision$ -# by Keiju ISHITSUKA(keiju@ruby-lang.org) +# $Release Version: 0.7 $ +# $Revision$ +# by Keiju ISHITSUKA(keiju@ruby-lang.org) # # -- # diff --git a/lib/shell/filter.rb b/lib/shell/filter.rb index d07cc3dd07..df41b420ea 100644 --- a/lib/shell/filter.rb +++ b/lib/shell/filter.rb @@ -1,8 +1,8 @@ # # shell/filter.rb - -# $Release Version: 0.7 $ -# $Revision$ -# by Keiju ISHITSUKA(keiju@ruby-lang.org) +# $Release Version: 0.7 $ +# $Revision$ +# by Keiju ISHITSUKA(keiju@ruby-lang.org) # # -- # @@ -19,8 +19,8 @@ class Shell include Enumerable def initialize(sh) - @shell = sh # parent shell - @input = nil # input filter + @shell = sh # parent shell + @input = nil # input filter end attr_reader :input diff --git a/lib/shell/process-controller.rb b/lib/shell/process-controller.rb index d50371fbbf..30f2229d39 100644 --- a/lib/shell/process-controller.rb +++ b/lib/shell/process-controller.rb @@ -1,8 +1,8 @@ # # shell/process-controller.rb - -# $Release Version: 0.7 $ -# $Revision$ -# by Keiju ISHITSUKA(keiju@ruby-lang.org) +# $Release Version: 0.7 $ +# $Revision$ +# by Keiju ISHITSUKA(keiju@ruby-lang.org) # # -- # @@ -157,19 +157,19 @@ class Shell @waiting_jobs.delete command else command = @waiting_jobs.shift - # command.notify "job(%id) pre-start.", @shell.debug? +# command.notify "job(%id) pre-start.", @shell.debug? return unless command end @active_jobs.push command command.start - # command.notify "job(%id) post-start.", @shell.debug? +# command.notify "job(%id) post-start.", @shell.debug? # start all jobs that input from the job for job in @waiting_jobs.dup start_job(job) if job.input == command end - # command.notify "job(%id) post2-start.", @shell.debug? +# command.notify "job(%id) post2-start.", @shell.debug? end end @@ -254,20 +254,20 @@ class Shell pid = fork { Thread.list.each do |th| - # th.kill unless [Thread.main, Thread.current].include?(th) - th.kill unless Thread.current == th +# th.kill unless [Thread.main, Thread.current].include?(th) + th.kill unless Thread.current == th end - STDIN.reopen(pipe_peer_in) - STDOUT.reopen(pipe_peer_out) + STDIN.reopen(pipe_peer_in) + STDOUT.reopen(pipe_peer_out) - ObjectSpace.each_object(IO) do |io| - if ![STDIN, STDOUT, STDERR].include?(io) - io.close unless io.closed? + ObjectSpace.each_object(IO) do |io| + if ![STDIN, STDOUT, STDERR].include?(io) + io.close unless io.closed? + end end - end - yield + yield } end pid_cv.signal @@ -283,8 +283,8 @@ class Shell rescue Errno::ECHILD command.notify "warn: job(%id) was done already waitpid." _pid = true - # rescue - # STDERR.puts $! + # rescue + # STDERR.puts $! ensure command.notify("Job(%id): Wait to finish when Process finished.", @shell.debug?) # when the process ends, wait until the command terminates @@ -296,11 +296,11 @@ class Shell redo end - # command.notify "job(%id) pre-pre-finish.", @shell.debug? +# command.notify "job(%id) pre-pre-finish.", @shell.debug? @job_monitor.synchronize do - # command.notify "job(%id) pre-finish.", @shell.debug? +# command.notify "job(%id) pre-finish.", @shell.debug? terminate_job(command) - # command.notify "job(%id) pre-finish2.", @shell.debug? +# command.notify "job(%id) pre-finish2.", @shell.debug? @job_condition.signal command.notify "job(%id) finish.", @shell.debug? end diff --git a/lib/shell/system-command.rb b/lib/shell/system-command.rb index e97fab2549..50d994bb20 100644 --- a/lib/shell/system-command.rb +++ b/lib/shell/system-command.rb @@ -1,8 +1,8 @@ # # shell/system-command.rb - -# $Release Version: 0.7 $ -# $Revision$ -# by Keiju ISHITSUKA(keiju@ruby-lang.org) +# $Release Version: 0.7 $ +# $Revision$ +# by Keiju ISHITSUKA(keiju@ruby-lang.org) # # -- # @@ -141,9 +141,9 @@ class Shell # ex) # if you wish to output: - # "shell: job(#{@command}:#{@pid}) close pipe-out." - # then - # mes: "job(%id) close pipe-out." + # "shell: job(#{@command}:#{@pid}) close pipe-out." + # then + # mes: "job(%id) close pipe-out." # yorn: Boolean(@shell.debug? or @shell.verbose?) def notify(*opts, &block) @shell.notify(*opts) do |mes| diff --git a/lib/shell/version.rb b/lib/shell/version.rb index 946224c0cc..cbdb0e5e96 100644 --- a/lib/shell/version.rb +++ b/lib/shell/version.rb @@ -1,8 +1,8 @@ # # version.rb - shell version definition file -# $Release Version: 0.7$ -# $Revision$ -# by Keiju ISHITSUKA(keiju@ruby-lang.org) +# $Release Version: 0.7$ +# $Revision$ +# by Keiju ISHITSUKA(keiju@ruby-lang.org) # # -- # |