From 1d2c192d35dcaa0483eebd891fddef0e972c8a59 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> Date: Thu, 24 May 2001 07:13:56 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'v1_6_4_preview3'. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_6_4_preview3@1446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- doc/forwardable.rd | 84 +++++++++++ doc/forwardable.rd.jp | 81 ++++++++++ doc/irb/irb-tools.rd.jp | 185 +++++++++++++++++++++++ doc/irb/irb.rd | 377 ++++++++++++++++++++++++++++++++++++++++++++++ doc/irb/irb.rd.jp | 391 ++++++++++++++++++++++++++++++++++++++++++++++++ doc/shell.rd | 348 ++++++++++++++++++++++++++++++++++++++++++ doc/shell.rd.jp | 336 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 1802 insertions(+) create mode 100644 doc/forwardable.rd create mode 100644 doc/forwardable.rd.jp create mode 100644 doc/irb/irb-tools.rd.jp create mode 100644 doc/irb/irb.rd create mode 100644 doc/irb/irb.rd.jp create mode 100644 doc/shell.rd create mode 100644 doc/shell.rd.jp (limited to 'doc') diff --git a/doc/forwardable.rd b/doc/forwardable.rd new file mode 100644 index 0000000000..7272c374b6 --- /dev/null +++ b/doc/forwardable.rd @@ -0,0 +1,84 @@ + -- forwardable.rb + + $Release Version: 1.1 $ + $Revision$ + $Date$ + Original version by Tosh + +=begin + += Forwardable + +A Module to define delegations for selected methods to a class. + +== Usage + +Using through extending the class. + + class Foo + extend Forwardable + + def_delegators("@out", "printf", "print") + def_delegators(:@in, :gets) + def_delegator(:@contents, :[], "content_at") + end + f = Foo.new + f.printf ... + f.gets + f.content_at(1) + +== Methods + +--- Forwardable#def_instance_delegators(accessor, *methods) + + adding the delegations for each method of ((|methods|)) to + ((|accessor|)). + +--- Forwardable#def_instance_delegator(accessor, method, ali = method) + + adding the delegation for ((|method|)) to ((|accessor|)). When + you give optional argument ((|ali|)), ((|ali|)) is used as the + name of the delegation method, instead of ((|method|)). + +--- Forwardable#def_delegators(accessor, *methods) + + the alias of ((|Forwardable#def_instance_delegators|)). + +--- Forwardable#def_delegator(accessor, method, ali = method) + + the alias of ((|Forwardable#def_instance_delegator|)). + += SingleForwardable + +a Module to define delegations for selected methods to an object. + +== Usage + +Using through extending the object. + + g = Goo.new + g.extend SingleForwardable + g.def_delegator("@out", :puts) + g.puts ... + +== Methods + +--- SingleForwardable#def_singleton_delegators(accessor, *methods) + + adding the delegations for each method of ((|methods|)) to + ((|accessor|)). + +--- SingleForwardable#def_singleton_delegator(accessor, method, ali = method) + + adding the delegation for ((|method|)) to ((|accessor|)). When + you give optional argument ((|ali|)), ((|ali|)) is used as the + name of the delegation method, instead of ((|method|)). + +--- SingleForwardable#def_delegators(accessor, *methods) + + the alias of ((|SingleForwardable#def_instance_delegators|)). + +--- SingleForwardable#def_delegator(accessor, method, ali = method) + + the alias of ((|SingleForwardable#def_instance_delegator|)). +=end diff --git a/doc/forwardable.rd.jp b/doc/forwardable.rd.jp new file mode 100644 index 0000000000..d928fddc5e --- /dev/null +++ b/doc/forwardable.rd.jp @@ -0,0 +1,81 @@ + -- forwatable.rb + $Release Version: 1.1 $ + $Revision$ + $Date$ + +=begin += Forwardable + +クラスに対しメソッドの委譲機能を定義します. + +== 使い方 + +クラスに対してextendして使います. + + class Foo + extend Forwardable + + def_delegators("@out", "printf", "print") + def_delegators(:@in, :gets) + def_delegator(:@contents, :[], "content_at") + end + f = Foo.new + f.printf ... + f.gets + f.content_at(1) + +== メソッド + +--- Forwardable#def_instance_delegators(accessor, *methods) + + ((|methods|))で渡されたメソッドのリストを((|accessorに|))委譲する + ようにします. + +--- Forwardable#def_instance_delegator(accessor, method, ali = method) + + ((||method|))で渡されたメソッドを((|accessor|))に委譲するようにし + ます. ((|ali|))が引数として渡されたときは, メソッド((|ali|))が呼ば + れたときには, ((|accessor|))に対し((|method|))を呼び出します. + +--- Forwardable#def_delegators(accessor, *methods) + + ((|Forwardable#def_instance_delegators|))の別名です. + +--- Forwardable#def_delegator(accessor, method, ali = method) + + ((|Forwardable#def_instance_delegator|))の別名です. + += SingleForwardable + +オブジェクトに対し, メソッドの委譲機能を定義します. + +== 使い方 + +オブジェクトに対して((|extend|))して使います. + + g = Goo.new + g.extend SingleForwardable + g.def_delegator("@out", :puts) + g.puts ... + +== メソッド + +--- SingleForwardable#def_singleton_delegators(accessor, *methods) + + ((|methods|))で渡されたメソッドのリストを((|accessor|))に委譲する + ようにします. + +--- SingleForwardable#def_singleton_delegator(accessor, method, ali = method) + + ((|method|))で渡されたメソッドを((|accessor|))に委譲するようにしま + す. ((|ali|))が引数として渡されたときは, メソッド((|ali|))が呼ばれ + たときには, ((|accessor|))に対し((|method|))を呼び出します. + +--- SingleForwardable#def_delegators(accessor, *methods) + + ((|SingleForwardable#def_singleton_delegators|))の別名です. + +--- SingleForwardable#def_delegator(accessor, method, ali = method) + + ((|SingleForwardable#def_singleton_delegator|))の別名です. +=end diff --git a/doc/irb/irb-tools.rd.jp b/doc/irb/irb-tools.rd.jp new file mode 100644 index 0000000000..64d9ab29c8 --- /dev/null +++ b/doc/irb/irb-tools.rd.jp @@ -0,0 +1,185 @@ +irb関連おまけコマンドとライブラリ + $Release Version: 0.7.1 $ + $Revision$ + $Date$ + by Keiju ISHITSUKA(Nihon Rational Co.,Ltd.) + +=begin + +:コマンド: +* rtags -- ruby tags command + +:関数ライブラリ: +* xmp -- irb version of gotoken xmp-function + +:クラスライブラリ: +* frame.rb -- frame tracer +* completion.rb -- irb completor + += rtags + +rtagsはemacs及びvi用の, TAGファイルをつくるコマンドです. + +== 使い方 + + rtags [-vi] file.... + +カレントディレクトリにemacs用のTAGSファイルができます. -viオプションを +つけた時にはvi用のtagsファイルを作成します. + +emacsの場合, 通常のetags.elがそのまま使えます. 検索可能なのは, + +* クラス +* メソッド +* 特異メソッド +* alias +* attrで宣言されたアクセサ(パラメータがシンボルか文字列リテラルに限る) +* attr_XXXで宣言されたアクセサ(パラメータがシンボルか文字列リテラルに限る) + +です. + +Cなどで使っているのと違うのは, コンプリーションに関する部分で, + +関数名は, + + 関数名( + +クラスは, + + ::クラス名::....::クラス名 + +メソッドは, + + ::クラス名::....::クラス名#メソッド名 + +特異メソッド(クラスメソッド)は + + ::クラス名::....::クラス名.メソッド名 + +でコンプリーションを行なうところです. + += xmp.rb + +ごとけんxmpの上位互換バージョンです. ただ, 非常に重いのでごとけんxmpで +は対応できない時に, 使用すると良いでしょう. + +== 使い方 + +=== 関数として使う. + + require "irb/xmp" + xmp <1 + foo + ==>1 + +=== XMPインスタンスを用いる. + +この場合は, XMPがコンテキスト情報を持つので, 変数の値などを保持してい +ます. + + require "irb/xmp" + xmp = XMP.new + xmp.puts <1 + foo + ==>1 + foo + ==>1 + +== コンテキストに関して + +XMPメソッド群のコンテキストは, 呼び出す前のコンテキストで評価されます. +明示的にコンテキストを指定するとそのコンテキストで評価します. + +例: + + xmp "foo", an_binding + +:注: +マルチスレッドには対応していません. + += frame.rb +現在実行中のフレーム情報を取り扱うためのクラスです. + +* IRB::Frame.top(n = 0) + 上からn番目のコンテキストを取り出します. nは0が最上位になります. +* IRB::Frame.bottom(n = 0) + 下からn番目のコンテキストを取り出します. nは0が最下位になります. +* IRB::Frame.sender + センダになっているオブジェクトを取り出します. センダとは, そのメソッ + ドを呼び出した側のselfのことです. + +:注: +set_trace_funcを用いてRubyの実行をトレースしています. マルチスレッドに +は対応していません. + += completion.rb +irbのcompletion機能を提供するものです. + +== 使い方 + + % irb -r irb/completion + +とするか, ~/.irbrc 中に + + require "irb/completion" + +を入れてください. irb実行中に require "irb/completion" してもよいです. + +irb実行中に (TAB) を押すとコンプレーションします. + +トップレベルで(TAB)を押すとすべての構文要素, クラス, メソッドの候補がで +ます. 候補が唯一ならば完全に補完します. + + irb(main):001:0> in + in inspect instance_eval + include install_alias_method instance_of? + initialize install_aliases instance_variables + irb(main):001:0> inspect + "main" + irb(main):002:0> foo = Object.new + # + + ((|変数名.|))の後に(TAB)を押すと, そのオブジェクトのメソッド一覧がでま + す. + + irb(main):003:0> foo. + foo.== foo.frozen? foo.protected_methods + foo.=== foo.hash foo.public_methods + foo.=~ foo.id foo.respond_to? + foo.__id__ foo.inspect foo.send + foo.__send__ foo.instance_eval foo.singleton_methods + foo.class foo.instance_of? foo.taint + foo.clone foo.instance_variables foo.tainted? + foo.display foo.is_a? foo.to_a + foo.dup foo.kind_of? foo.to_s + foo.eql? foo.method foo.type + foo.equal? foo.methods foo.untaint + foo.extend foo.nil? + foo.freeze foo.private_methods + +=end + +% Begin Emacs Environment +% Local Variables: +% mode: text +% comment-column: 0 +% comment-start: "%" +% comment-end: "\n" +% End: +% + diff --git a/doc/irb/irb.rd b/doc/irb/irb.rd new file mode 100644 index 0000000000..528e5e17fb --- /dev/null +++ b/doc/irb/irb.rd @@ -0,0 +1,377 @@ +irb -- interactive ruby + $Release Version: 0.5 $ + $Revision$ + $Date$ + by Keiju ISHITSUKA(keiju@ishitsuka.com) + translate from japanese by gotoken-san + +=begin += What is irb? + +irb stands for `interactive ruby'. irb is a tool to execute interactively +ruby expressions read from stdin. + += Invoking + + % ruby -r irb -e0 + % irb + +Either of the aboves. In the former style, options can be specified +as follows: + + % ruby -r irb -e0 -- -v + += Usage + +Use of irb is easy if you know ruby. Executing irb, prompts are +displayed as follows. Then, enter expression of ruby. A input is +executed when it is syntacticaly completed. + + dim% irb + irb(main):001:0> 1+2 + 3 + irb(main):002:0> class Foo + irb(main):003:1> def foo + irb(main):004:2> print 1 + irb(main):005:2> end + irb(main):006:1> end + nil + irb(main):007:0> + +And, Readline extesion module can be used with irb. Using Readline +is the standard default action if Readline is installed. + += Command line option + + irb.rb [options] file_name opts + options: + -f suppress read ~/.irbrc + -m bc mode (fraction or matrix are available) + -d set $DEBUG to true (same as `ruby -d') + -r load-module same as `ruby -r' + --inspect uses `inspect' for output (the default except bc mode) + --noinspect doesn't uses inspect for output + --readline uses Readline extension module + --noreadline doesn't use Readline extension module + --prompt prompt-mode + --prompt-mode prompt-mode + switches prompt mode. Pre-defined prompt modes are + `defalut', `simple', `xmp' and `inf-ruby' + + --inf-ruby-mode uses prompt appreciate for inf-ruby-mode on emacs. + Suppresses --readline. + --simple-prompt simple prompt mode + --noprompt no prompt + --tracer display trace for each execution of commands. + --back-trace-limit n + displayes backtrace top n and tail n. The default + value is 16. + --irb_debug n sets internal debug level to n (It shouldn't be used) + -v, --version prints the version of irb + + + += Configurations + +irb reads `~/.irbrc' when it is invoked. If `~/.irbrb' doesn't exist +irb try to read in the order `.irbrc', `irb.rc', `_irbrc' then `$irbrc'. + +The following is altanative to the command line option. To use them +type as follows in an irb session. + + IRB.conf[:IRB_NAME]="irb" + IRB.conf[:MATH_MODE]=false + IRB.conf[:USE_TRACER]=false + IRB.conf[:USE_LOADER]=false + IRB.conf[:IGNORE_SIGINT]=true + IRB.conf[:IGNORE_EOF]=false + IRB.conf[:INSPECT_MODE]=nil + IRB.conf[:IRB_RC] = nil + IRB.conf[:BACK_TRACE_LIMIT]=16 + IRB.conf[:USE_LOADER] = false + IRB.conf[:USE_READLINE] = nil + IRB.conf[:USE_TRACER] = false + IRB.conf[:IGNORE_SIGINT] = true + IRB.conf[:IGNORE_EOF] = false + IRB.conf[:PROMPT_MODE] = :DEFALUT + IRB.conf[:PROMPT] = {...} + IRB.conf[:DEBUG_LEVEL]=0 + IRB.conf[:VERBOSE]=true + +== Customizing prompt + +To costomize the prompt you set a variable + + IRB.conf[:PROMPT] + +For example, describe as follows in `.irbrc'. + + IRB.conf[:PROMPT][:MY_PROMPT] = { # name of prompt mode + :PROMPT_I => nil, # normal prompt + :PROMPT_S => nil, # prompt for continuated strings + :PROMPT_C => nil, # prompt for continuated statement + :RETURN => " ==>%s\n" # format to return value + } + +Then, invoke irb with the above prompt mode by + + % irb --prompt my-prompt + +Or add the following in `.irbrc'. + + IRB.conf[:PROMPT_MODE] = :MY_PROMPT + +Constants PROMPT_I, PROMPT_S and PROMPT_C specifies the format. +In the prompt specification, some special strings are available. + + %N command name which is running + %m to_s of main object (self) + %M inspect of main object (self) + %l type of string(", ', /, ]), `]' is inner %w[...] + %NNi indent level. NN is degits and means as same as printf("%NNd"). + It can be ommited + %NNn line number. + %% % + +For instance, the default prompt mode is defined as follows: + +IRB.conf[:PROMPT_MODE][:DEFAULT] = { + :PROMPT_I => "%N(%m):%03n:%i> ", + :PROMPT_S => "%N(%m):%03n:%i%l ", + :PROMPT_C => "%N(%m):%03n:%i* ", + :RETURN => "%s\n" +} + +RETURN is used to printf. + +== Configurating subirb + +The command line option or IRB.conf specify the default behavior of +(sub)irb. On the other hand, each conf of in the next sction `6. Command' +is used to individually configurate (sub)irb. + +If proc is set to IRB.conf[:IRB_RC], its subirb will be invoked after +execution of that proc under giving the context of irb as its +aregument. By this mechanism each subirb can be configurated. + += Command + +For irb commands, both simple name and `irb_'-prefixed name are prepared. + +--- exit, quit, irb_exit + Quits (sub)irb. + if you've done cb (see below), exit from the binding mode. + +--- conf, irb_context + Displays current configuration. Modifing the configuration is + achieved by sending message to `conf'. + +--- conf.back_trace_limit + Sets display lines of backtrace as top n and tail n. + The default value is 16. + +--- conf.debug_level = N + Sets debug level of irb. + +--- conf.ignore_eof = true/false + Whether ^D (control-d) will be ignored or not. + If false is set, ^D means quit. + +--- conf.ignore_sigint= true/false + Whether ^C (control-c) will be ignored or not. + If false is set, ^D means quit. If true, + during input: cancel inputing then return to top level. + during execute: abondon current execution. + +--- conf.inf_ruby_mode = true/false + Whether inf-ruby-mode or not. The default value is false. + +--- conf.inspect_mode = true/false/nil + Specifies inspect mode. + true: display inspect + false: display to_s + nil: inspect mode in non math mode, + non inspect mode in math mode. + +--- conf.irb_level + The level of cb. + +--- conf.math_mode + Whether bc mode or not. + +--- conf.use_loader = true/false + Whether irb's own file reader method is used when load/require or not. + This mode is globaly affected (irb wide). + +--- conf.prompt_c + prompt for a continuating statement (e.g, immediately after of `if') + +--- conf.prompt_i + standard prompt + +--- conf.prompt_s + prompt for a continuating string + +--- conf.rc + Whether ~/.irbrc is read or not. + +--- conf.use_prompt = true/false + Prompting or not. + +--- conf.use_readline = true/false/nil + Whether readline is used or not. + true: uses + false: doen't use + nil: intends to use readline except for inf-reuby-mode (default) + +--- conf.verbose=T/F + Whether verbose messages are display or not. + +--- cb, irb_change_binding [obj] + Enter new binding which has a distinct scope of local variables. + If obj is given, obj will be self. + +--- irb [obj] + Invoke subirb. If obj is given, obj will be self. + +--- jobs, irb_jobs + List of subirb + +--- fg n, irb_fg n + Switch into specified subirb. The following is candidates of n: + + irb number + thhread + irb object + self(obj which is specified of irb obj) + +--- kill n, irb_kill n + Kill subirb. The means of n is as same as the case of irb_fg. + += System variable + + _ The latest value of evaluation (it is local) + + += Session Example + + dim% ruby irb.rb + irb(main):001:0> irb # invoke subirb + irb#1(main):001:0> jobs # list of subirbs + #0->irb on main (# : stop) + #1->irb#1 on main (# : running) + nil + irb#1(main):002:0> fg 0 # switch job + nil + irb(main):002:0> class Foo;end + nil + irb(main):003:0> irb Foo # invoke subirb which has the + # context of Foo + irb#2(Foo):001:0> def foo # define Foo#foo + irb#2(Foo):002:1> print 1 + irb#2(Foo):003:1> end + nil + irb#2(Foo):004:0> fg 0 # switch job + nil + irb(main):004:0> jobs # list of job + #0->irb on main (# : running) + #1->irb#1 on main (# : stop) + #2->irb#2 on Foo (# : stop) + nil + irb(main):005:0> Foo.instance_methods # Foo#foo is defined asurely + ["foo"] + irb(main):006:0> fg 2 # switch job + nil + irb#2(Foo):005:0> def bar # define Foo#bar + irb#2(Foo):006:1> print "bar" + irb#2(Foo):007:1> end + nil + irb#2(Foo):010:0> Foo.instance_methods + ["bar", "foo"] + irb#2(Foo):011:0> fg 0 + nil + irb(main):007:0> f = Foo.new + # + irb(main):008:0> irb f # invoke subirb which has the + # context of f (instance of Foo) + irb#3(#):001:0> jobs + #0->irb on main (# : stop) + #1->irb#1 on main (# : stop) + #2->irb#2 on Foo (# : stop) + #3->irb#3 on # (# : running) + nil + irb#3(#):002:0> foo # evaluate f.foo + 1nil + irb#3(#):003:0> bar # evaluate f.bar + barnil + irb#3(#):004:0> kill 1, 2, 3# kill job + nil + irb(main):009:0> jobs + #0->irb on main (# : running) + nil + irb(main):010:0> exit # exit + dim% + += Restrictions + +Because irb evaluates the inputs immediately after the imput is +syntactically completed, irb gives slight different result than +directly use ruby. Known difference is pointed out here. + + +== Declaration of the local variable + +The following causes an error in ruby: + + eval "foo = 0" + foo + -- + -:2: undefined local variable or method `foo' for # (NameError) + --- + NameError + +Though, the above will successfully done by irb. + + >> eval "foo = 0" + => 0 + >> foo + => 0 + +Ruby evaluates a code after reading entire of code and determination +of the scope of local variables. On the other hand, irb do +immediately. More precisely, irb evaluate at first + + evel "foo = 0" + +then foo is defined on this timing. It is because of this +incompatibility. + +If you'd like to detect those differences, begin...end can be used: + + >> begin + ?> eval "foo = 0" + >> foo + >> end + NameError: undefined local variable or method `foo' for # + (irb):3 + (irb_local_binding):1:in `eval' + +== Here-document + +Implementation of Here-document is incomplete. + +== Symbol + +Irb can not always recognize a symbol as to be Symbol. Concretely, an +expression have completed, however Irb regard it as continuation line. + +=end + +% Begin Emacs Environment +% Local Variables: +% mode: text +% comment-column: 0 +% comment-start: "%" +% comment-end: "\n" +% End: +% diff --git a/doc/irb/irb.rd.jp b/doc/irb/irb.rd.jp new file mode 100644 index 0000000000..8b0de3cc62 --- /dev/null +++ b/doc/irb/irb.rd.jp @@ -0,0 +1,391 @@ +irb -- interactive ruby + $Release Version: 0.6 $ + $Revision$ + $Date$ + by Keiju ISHITSUKA(keiju@ishitsuka.com) +=begin += irbとは? + +irbはinteractive rubyの略です. rubyの式を標準入力から簡単に入力/実行す +るためのツールです. + += 起動 + + % ruby -r irb -e0 + % irb + +のいずれかで行ないます. 前者の場合irbへのオプション指定は, 以下のように +なります. + + % ruby -r irb -e0 -- -v + += 使い方 + +irbの使い方は, Rubyさえ知っていればいたって簡単です. 基本的には irb と +いうコマンドを実行するだけです. irbを実行すると, 以下のようなプロンプ +トが表れてきます. 後は, rubyの式を入れて下さい. 式が完結した時点で実行 +されます. + + dim% irb + irb(main):001:0> 1+2 + 3 + irb(main):002:0> class Foo + irb(main):003:1> def foo + irb(main):004:2> print 1 + irb(main):005:2> end + irb(main):006:1> end + nil + irb(main):007:0> + +また, irbはReadlineモジュールにも対応しています. Readlineモジュールが +インストールされている時には, それを使うのが標準の動作になります. + += コマンドオプション + + irb.rb [options] file_name opts + options: + -f ~/.irbrc を読み込まない. + -m bcモード(分数, 行列の計算ができる) + -d $DEBUG をtrueにする(ruby -d と同じ) + -r load-module ruby -r と同じ. + --inspect 結果出力にinspectを用いる(bcモード以外はデフォルト). + --noinspect 結果出力にinspectを用いない. + --readline readlineライブラリを利用する. + --noreadline readlineライブラリを利用しない. デフォルトの動作は, + inf-reuby-mode以外でreadlineライブラリを利用しよう + とする. + --prompt prompt-mode + --prompt-mode prompt-mode + プロンプトモードを切替えます. 現在定義されているプ + ロンプトモードは, defalut, simple, xmp, inf-rubyが + 用意されています. デフォルトはdefaultプロンプトモー + ドになっています. + + --inf-ruby-mode emacsのinf-ruby-mode用のプロンプト表示を行なう. 特 + に指定がない限り, readlineライブラリは使わなくなる. + --simple-prompt + 非常にシンプルなプロンプトを用いるモードです. + --noprompt プロンプト表示を行なわない. + --tracer コマンド実行時にトレースを行なう. + --back-trace-limit n + バックトレース表示をバックトレースの頭から n, 後ろ + からnだけ行なう. デフォルトは16 + --irb_debug n irbのデバッグデバッグレベルをnに設定する(利用しな + い方が無難でしょう). + -v, --version irbのバージョンを表示する + += コンフィギュレーション + +irb起動時に``~/.irbrc''を読み込みます. もし存在しない場合は, +``.irbrc'', ``irb.rc'', ``_irbrc'', ``$irbrc''の順にloadを試みます. + +オプションを設定する代わりに, 以下のコマンドでもデフォルトの動作を設定 +できます. + + IRB.conf[:IRB_NAME]="irb" + IRB.conf[:MATH_MODE]=false + IRB.conf[:USE_TRACER]=false + IRB.conf[:USE_LOADER]=false + IRB.conf[:IGNORE_SIGINT]=true + IRB.conf[:IGNORE_EOF]=false + IRB.conf[:INSPECT_MODE]=nil + IRB.conf[:IRB_RC] = nil + IRB.conf[:BACK_TRACE_LIMIT]=16 + IRB.conf[:USE_LOADER] = false + IRB.conf[:USE_READLINE] = nil + IRB.conf[:USE_TRACER] = false + IRB.conf[:IGNORE_SIGINT] = true + IRB.conf[:IGNORE_EOF] = false + IRB.conf[:PROMPT_MODE] = :DEFALUT + IRB.conf[:PROMPT] = {...} + IRB.conf[:DEBUG_LEVEL]=0 + IRB.conf[:VERBOSE]=true + +== プロンプトの設定 + +プロンプトをカスタマイズしたい時には, + + IRB.conf[:PROMPT] + +を用います. 例えば, .irbrcの中で下のような式を記述します: + + IRB.conf[:PROMPT][:MY_PROMPT] = { # プロンプトモードの名前 + :PROMPT_I => nil, # 通常のプロンプト + :PROMPT_S => nil, # 文字列などの継続行のプロンプト + :PROMPT_C => nil, # 式が継続している時のプロンプト + :RETURN => " ==>%s\n" # リターン時のプロンプト + } + +プロンプトモードを指定したい時には, + + irb --prompt my-prompt + +でそのプロンプトモードで起動されます. または, .irbrcに下式を記述しても +OKです. + + IRB.conf[:PROMPT_MODE] = :MY_PROMPT + +PROMPT_I, PROMPT_S, PROMPT_Cは, フォーマットを指定します. + + %N 起動しているコマンド名が出力される. + %m mainオブジェクト(self)がto_sで出力される. + %M mainオブジェクト(self)がinspectされて出力される. + %l 文字列中のタイプを表す(", ', /, ], `]'は%wの中の時) + %NNi インデントのレベルを表す. NNは数字が入りprintfの%NNdと同じ. 省 + 略可能 + %NNn 行番号を表します. + %% % + +例えば, デフォルトのプロンプトモードは: + + IRB.conf[:PROMPT_MODE][:DEFAULT] = { + :PROMPT_I => "%N(%m):%03n:%i> ", + :PROMPT_S => "%N(%m):%03n:%i%l ", + :PROMPT_C => "%N(%m):%03n:%i* ", + :RETURN => "%s\n" + } + +となっています. + +RETURNは, 現在のところprintf形式です. 将来仕様が変わるかも知れません. + +== サブirbの設定 + +コマンドラインオプションおよびIRB.confは(サブ)irb起動時のデフォルトの +設定を決めるもので, `5. コマンド'にあるconfで個別の(サブ)irbの設定がで +きるようになっています. + +IRB.conf[:IRB_RC]にprocが設定されていると, サブirbを起動する時にその +procをirbのコンテキストを引数として呼び出します. これによって個別のサ +ブirbごとに設定を変えることができるようになります. + + += コマンド + +irb拡張コマンドは, 簡単な名前と頭に`irb_'をつけた名前と両方定義されて +います. これは, 簡単な名前がoverrideされた時のためです. + +--- exit, quit, irb_exit + 終了する. + サブirbの場合, そのサブirbを終了する. + cbしている場合, そのバインディングのモードを終了する. + +--- conf, irb_context + irbの現在の設定を表示する. 設定の変更は, confにメッセージを送るこ + とによって行なえる. + +--- conf.back_trace_limit + バックトレース表示をバックトレースの頭からn, 後ろからnだけ行なう. + デフォルトは16 + +--- conf.debug_level = N + irb用のデバッグレベルの設定 + +--- conf.ignore_eof = true/false + ^Dが入力された時の動作を設定する. trueの時は^Dを無視する, falseの + 時はirbを終了する. + +--- conf.ignore_sigint= true/false + ^Cが入力された時の動作を設定する. false時は, irbを終了する. trueの + 時の動作は以下のようになる: + 入力中: これまで入力したものをキャンセルしトップレベルに戻る. + 実行中: 実行を中止する. + +--- conf.inf_ruby_mode = true/false + inf-ruby-mode用のプロンプト表示を行なう. デフォルトはfalse. + +--- conf.inspect_mode = true/false/nil + インスペクトモードを設定する. + true: インスペクトして表示する. + false: 通常のprintで表示する. + nil: 通常モードであれば, inspect modeとなり, mathモードの時は, non + inspect modeとなる. + +--- conf.irb_level + 参照のみ. irbが何段cbしているか? + +--- conf.math_mode + 参照のみ. bcモード(分数, 行列の計算ができます)かどうか? + +--- conf.use_loader = true/false + load/require時にirbのfile読み込み機能を用いるモードのスイッチ(デフォ + ルトは用いない). このモードはIRB全体に反映される. + +--- conf.prompt_c + ifの直後など, 行が継続している時のプロンプト. + +--- conf.prompt_i + 通常のプロンプト. + +--- conf.prompt_s + 文字列中などを表すプロンプト. + +--- conf.rc + ~/.irbrcを読み込んだかどうか? + +--- conf.use_prompt = true/false + プロンプト表示するかどうか? デフォルトではプロンプトを表示する. + +--- conf.use_readline = true/false/nil + readlineを使うかどうか? + true: readlineを使う. + false: readlineを使わない. + nil: (デフォルト)inf-reuby-mode以外でreadlineライブラリを利用しよ + うとする. + +--- conf.verbose=T/F + irbからいろいろなメッセージを出力するか? + +--- cb, irb_change_binding [obj] + ローカル変数のスコープが違う新たなbindingに移る. objが指定された + 時は, そのobjをselfとする. + +--- irb [obj] + サブirbを立ちあげる. objが指定された時は, そのobjをselfとする. + +--- jobs, irb_jobs + サブirbのリスト + +--- fg n, irb_fg n + 指定したサブirbにスイッチする. nは, 次のものを指定する. + + irb番号 + スレッド + irbオブジェクト + self(irb objで起動した時のobj) + +--- kill n, irb_kill n + サブirbをkillする. nはfgと同じ. + + += システム変数 + + _ 前の計算の実行結果を覚えている(ローカル変数). + += 使用例 + +以下のような感じです. + + dim% ruby irb.rb + irb(main):001:0> irb # サブirbの立ちあげ + irb#1(main):001:0> jobs # サブirbのリスト + #0->irb on main (# : stop) + #1->irb#1 on main (# : running) + nil + irb#1(main):002:0> fg 0 # jobのスイッチ + nil + irb(main):002:0> class Foo;end + nil + irb(main):003:0> irb Foo # Fooをコンテキストしてirb + # 立ちあげ + irb#2(Foo):001:0> def foo # Foo#fooの定義 + irb#2(Foo):002:1> print 1 + irb#2(Foo):003:1> end + nil + irb#2(Foo):004:0> fg 0 # jobをスイッチ + nil + irb(main):004:0> jobs # jobのリスト + #0->irb on main (# : running) + #1->irb#1 on main (# : stop) + #2->irb#2 on Foo (# : stop) + nil + irb(main):005:0> Foo.instance_methods # Foo#fooがちゃんと定義さ + # れている + ["foo"] + irb(main):006:0> fg 2 # jobをスイッチ + nil + irb#2(Foo):005:0> def bar # Foo#barを定義 + irb#2(Foo):006:1> print "bar" + irb#2(Foo):007:1> end + nil + irb#2(Foo):010:0> Foo.instance_methods + ["bar", "foo"] + irb#2(Foo):011:0> fg 0 + nil + irb(main):007:0> f = Foo.new + # + irb(main):008:0> irb f # Fooのインスタンスでirbを + # 立ちあげる. + irb#3(#):001:0> jobs + #0->irb on main (# : stop) + #1->irb#1 on main (# : stop) + #2->irb#2 on Foo (# : stop) + #3->irb#3 on # (# : running) + nil + irb#3(#):002:0> foo # f.fooの実行 + nil + irb#3(#):003:0> bar # f.barの実行 + barnil + irb#3(#):004:0> kill 1, 2, 3# jobのkill + nil + irb(main):009:0> jobs + #0->irb on main (# : running) + nil + irb(main):010:0> exit # 終了 + dim% + += 使用上の制限 + +irbは, 評価できる時点(式が閉じた時点)での逐次実行を行ないます. したがっ +て, rubyを直接使った時と, 若干異なる動作を行なう場合があります. + +現在明らかになっている問題点を説明します. + +== ローカル変数の宣言 + +rubyでは, 以下のプログラムはエラーになります. + + eval "foo = 0" + foo + -- + -:2: undefined local variable or method `foo' for # (NameError) + --- + NameError + +ところが, irbを用いると + + >> eval "foo = 0" + => 0 + >> foo + => 0 + +となり, エラーを起こしません. これは, rubyが最初にスクリプト全体をコン +パイルしてローカル変数を決定するからです. それに対し, irbは実行可能に +なる(式が閉じる)と自動的に評価しているからです. 上記の例では, + + evel "foo = 0" + +を行なった時点で評価を行ない, その時点で変数が定義されるため, 次式で +変数fooは定義されているからです. + +このようなrubyとirbの動作の違いを解決したい場合は, begin...endで括って +バッチ的に実行して下さい: + + >> begin + ?> eval "foo = 0" + >> foo + >> end + NameError: undefined local variable or method `foo' for # + (irb):3 + (irb_local_binding):1:in `eval' + +== ヒアドキュメント + +現在のところヒアドキュメントの実装は不完全です. + +== シンボル + +シンボルであるかどうかの判断を間違えることがあります. 具体的には式が完了 +しているのに継続行と見なすことがあります. + +=end + +% Begin Emacs Environment +% Local Variables: +% mode: text +% comment-column: 0 +% comment-start: "%" +% comment-end: "\n" +% End: +% + diff --git a/doc/shell.rd b/doc/shell.rd new file mode 100644 index 0000000000..02ee1b020a --- /dev/null +++ b/doc/shell.rd @@ -0,0 +1,348 @@ + -- shell.rb + $Release Version: 0.6.0 $ + $Revision$ + $Date$ + by Keiju ISHITSUKA(keiju@ishitsuka.com) + +=begin + += What's shell.rb? + +It realizes a wish to do execution of commands with filters and pipes +like sh/csh by using just native facilities of ruby. + += Main classes + +== Shell + +Every shell object has its own current working directory, and executes +each command as if it stands in the directory. + +--- Shell#cwd +--- Shell#dir +--- Shell#getwd +--- Shell#pwd + + Returns the current directory + +--- Shell#system_path + + Returns the command search path in an array + +--- Shell#umask + + Returns the umask + +== Filter + +Any result of command exection is a Filter. Filter include +Enumerable, therefore a Filter object can use all Enumerable +facilities. + += Main methods + +== Command definitions + +In order to execute a command on your OS, you need to define it as a +Shell method. + +Alternatively, you can execute any command via Shell#system even if it +is not defined. + +--- Shell.def_system_command(command, path = command) + + Defines a command. Registers as a Shell method + . + + ex) + Shell.def_system_command "ls" + Defines ls. + + Shell.def_system_command "sys_sort", "sort" + Defines sys_sort as sort. + +--- Shell.undef_system_command(command) + + Undefines a commmand + +--- Shell.alias_command(ali, command, *opts) {...} + + Aliases a command. + + ex) + Shell.alias_command "lsC", "ls", "-CBF", "--show-control-chars" + Shell.alias_command("lsC", "ls"){|*opts| ["-CBF", "--show-control-chars", *opts]} + +--- Shell.unalias_command(ali) + + Unaliases a command. + +--- Shell.install_system_commands(pre = "sys_") + + Defines all commands in the default_system_path as Shell method, + all with
 prefixed to their names.
+
+== Creation
+
+--- Shell.new
+
+      Creates a Shell object which current directory is set to the
+      process current directory.
+
+--- Shell.cd(path)
+
+      Creates a Shell object which current directory is set to
+      .
+
+== Process management
+
+--- Shell#jobs
+
+      Returns a list of scheduled jobs.
+
+--- Shell#kill sig, job
+
+      Sends a signal  to .
+
+== Current directory operations
+
+--- Shell#cd(path, &block)
+--- Shell#chdir
+
+      Changes the current directory to .  If a block is given,
+      it restores the current directory when the block ends.
+
+--- Shell#pushd(path = nil, &block)
+--- Shell#pushdir
+
+      Pushes the current directory to the directory stack, changing
+      the current directory to .  If  is omitted, it
+      exchanges its current directory and the top of its directory
+      stack.  If a block is given, it restores the current directory
+      when the block ends.
+
+--- Shell#popd
+--- Shell#popdir
+
+      Pops a directory from the directory stack, and sets the current
+      directory to it.
+
+== File and directory operations
+
+--- Shell#foreach(path = nil, &block)
+
+      Same as:
+        File#foreach (when path is a file)
+        Dir#foreach (when path is a directory)
+
+--- Shell#open(path, mode)
+
+      Same as:
+        File#open (when path is a file)
+        Dir#open (when path is a directory)
+
+--- Shell#unlink(path)
+
+      Same as:
+        Dir#open (when path is a file)
+        Dir#unlink (when path is a directory)
+
+--- Shell#test(command, file1, file2)
+--- Shell#[command, file1, file2]
+
+      Same as test().
+      ex)
+          sh[?e, "foo"]
+          sh[:e, "foo"]
+          sh["e", "foo"]
+          sh[:exists?, "foo"]
+          sh["exists?", "foo"]
+
+--- Shell#mkdir(*path)
+
+      Same as Dir.mkdir (with multiple directories allowed)
+
+--- Shell#rmdir(*path)
+
+      Same as Dir.rmdir (with multiple directories allowed)
+
+== Command execution
+
+--- System#system(command, *opts)
+
+      Executes  with .
+
+      ex)
+        print sh.system("ls", "-l")
+        sh.system("ls", "-l") | sh.head > STDOUT
+
+--- System#rehash
+
+      Does rehash.
+
+--- Shell#transact &block
+
+      Executes a block as self.
+      ex)
+        sh.transact{system("ls", "-l") | head > STDOUT}
+
+--- Shell#out(dev = STDOUT, &block)
+
+      Does transact, with redirecting the result output to .
+
+== Internal commands
+
+--- Shell#echo(*strings)
+--- Shell#cat(*files)
+--- Shell#glob(patten)
+--- Shell#tee(file)
+
+      Return Filter objects, which are results of their execution.
+
+--- Filter#each &block
+
+      Iterates a block for each line of it.
+
+--- Filter#<(src)
+
+      Inputs from , which is either a string of a file name or an
+      IO.
+
+--- Filter#>(to)
+
+      Outputs to , which is either a string of a file name or an
+      IO.
+
+--- Filter#>>(to)
+
+      Appends the ouput to , which is either a string of a file
+      name or an IO.
+
+--- Filter#|(filter)
+
+      Processes a pipeline.
+
+--- Filter#+(filter)
+
+      (filter1 + filter2) outputs filter1, and then outputs filter2.
+
+--- Filter#to_a
+--- Filter#to_s
+
+== Built-in commands
+
+--- Shell#atime(file)
+--- Shell#basename(file, *opt)
+--- Shell#chmod(mode, *files)
+--- Shell#chown(owner, group, *file)
+--- Shell#ctime(file)
+--- Shell#delete(*file)
+--- Shell#dirname(file)
+--- Shell#ftype(file)
+--- Shell#join(*file)
+--- Shell#link(file_from, file_to)
+--- Shell#lstat(file)
+--- Shell#mtime(file)
+--- Shell#readlink(file)
+--- Shell#rename(file_from, file_to)
+--- Shell#split(file)
+--- Shell#stat(file)
+--- Shell#symlink(file_from, file_to)
+--- Shell#truncate(file, length)
+--- Shell#utime(atime, mtime, *file)
+
+      Equivalent to the class methods of File with the same names.
+
+--- Shell#blockdev?(file)
+--- Shell#chardev?(file)
+--- Shell#directory?(file)
+--- Shell#executable?(file)
+--- Shell#executable_real?(file)
+--- Shell#exist?(file)/Shell#exists?(file)
+--- Shell#file?(file)
+--- Shell#grpowned?(file)
+--- Shell#owned?(file)
+--- Shell#pipe?(file)
+--- Shell#readable?(file)
+--- Shell#readable_real?(file)
+--- Shell#setgid?(file)
+--- Shell#setuid?(file)
+--- Shell#size(file)/Shell#size?(file)
+--- Shell#socket?(file)
+--- Shell#sticky?(file)
+--- Shell#symlink?(file)
+--- Shell#writable?(file)
+--- Shell#writable_real?(file)
+--- Shell#zero?(file)
+
+      Equivalent to the class methods of FileTest with the same names.
+
+--- Shell#syscopy(filename_from, filename_to)
+--- Shell#copy(filename_from, filename_to)
+--- Shell#move(filename_from, filename_to)
+--- Shell#compare(filename_from, filename_to)
+--- Shell#safe_unlink(*filenames)
+--- Shell#makedirs(*filenames)
+--- Shell#install(filename_from, filename_to, mode)
+
+      Equivalent to the class methods of FileTools with the same
+      names.
+
+      And also, there are some aliases for convenience:
+
+--- Shell#cmp	<- Shell#compare
+--- Shell#mv	<- Shell#move
+--- Shell#cp	<- Shell#copy
+--- Shell#rm_f	<- Shell#safe_unlink
+--- Shell#mkpath	<- Shell#makedirs
+
+= Samples
+
+== ex1
+
+  sh = Shell.cd("/tmp")
+  sh.mkdir "shell-test-1" unless sh.exists?("shell-test-1")
+  sh.cd("shell-test-1")
+  for dir in ["dir1", "dir3", "dir5"]
+    if !sh.exists?(dir)
+      sh.mkdir dir
+      sh.cd(dir) do
+	f = sh.open("tmpFile", "w")
+	f.print "TEST\n"
+	f.close
+      end
+      print sh.pwd
+    end
+  end
+
+== ex2
+
+  sh = Shell.cd("/tmp")
+  sh.transact do
+    mkdir "shell-test-1" unless exists?("shell-test-1")
+    cd("shell-test-1")
+    for dir in ["dir1", "dir3", "dir5"]
+      if !exists?(dir)
+	mkdir dir
+	cd(dir) do
+	  f = open("tmpFile", "w")
+	  f.print "TEST\n"
+	  f.close
+	end
+	print pwd
+      end
+    end
+  end
+
+== ex3
+
+  sh.cat("/etc/printcap") | sh.tee("tee1") > "tee2"
+  (sh.cat < "/etc/printcap") | sh.tee("tee11") > "tee12"
+  sh.cat("/etc/printcap") | sh.tee("tee1") >> "tee2"
+  (sh.cat < "/etc/printcap") | sh.tee("tee11") >> "tee12"
+
+== ex4
+
+  print sh.cat("/etc/passwd").head.collect{|l| l =~ /keiju/}
+
+=end
diff --git a/doc/shell.rd.jp b/doc/shell.rd.jp
new file mode 100644
index 0000000000..073e71ea42
--- /dev/null
+++ b/doc/shell.rd.jp
@@ -0,0 +1,336 @@
+ -- shell.rb
+				$Release Version: 0.6.0 $
+			   	$Revision$
+			   	$Date$
+			   	by Keiju ISHITSUKA(keiju@ishitsuka.com)
+
+=begin
+
+= 目的
+
+ruby上でsh/cshのようにコマンドの実行及びフィルタリングを手軽に行う.
+sh/cshの制御文はrubyの機能を用いて実現する.
+
+= 主なクラス一覧
+
+== Shell
+
+Shellオブジェクトはカレントディレクトリを持ち, コマンド実行はそこからの
+相対パスになります.
+
+--- Shell#cwd
+--- Shell#dir
+--- Shell#getwd
+--- Shell#pwd
+
+      カレントディレクトリを返す。
+
+--- Shell#system_path
+
+      コマンドサーチパスの配列を返す。
+
+--- Shell#umask
+
+      umaskを返す。
+
+== Filter
+
+コマンドの実行結果はすべてFilterとしてかえります. Enumerableをincludeし
+ています.
+
+= 主なメソッド一覧
+
+== コマンド定義
+
+OS上のコマンドを実行するにはまず, Shellのメソッドとして定義します.
+
+注) コマンドを定義しなくとも直接実行できるShell#systemコマンドもあります.
+
+--- Shell.def_system_command(command, path = command)
+
+      Shellのメソッドとしてcommandを登録します. 
+
+      例)
+      Shell.def_system_command "ls"
+        ls を定義
+
+      Shell.def_system_command "sys_sort", "sort"
+        sortコマンドをsys_sortとして定義
+
+--- Shell.undef_system_command(command)
+
+      commandを削除します.
+
+--- Shell.alias_command(ali, command, *opts) {...}
+
+      commandのaliasをします. 
+
+      例)
+        Shell.alias_command "lsC", "ls", "-CBF", "--show-control-chars"
+        Shell.alias_command("lsC", "ls"){|*opts| ["-CBF", "--show-control-chars", *opts]}
+
+--- Shell.unalias_command(ali)
+
+      commandのaliasを削除します.
+
+--- Shell.install_system_commands(pre = "sys_")
+
+      system_path上にある全ての実行可能ファイルをShellに定義する. メソッ
+      ド名は元のファイル名の頭にpreをつけたものとなる.
+
+== 生成
+
+--- Shell.new
+
+      プロセスのカレントディレクトリをカレントディレクトリとするShellオ
+      ブジェクトを生成します.
+
+--- Shell.cd(path)
+
+      pathをカレントディレクトリとするShellオブジェクトを生成します.
+
+== プロセス管理
+
+--- Shell#jobs
+
+      スケジューリングされているjobの一覧を返す.
+
+--- Shell#kill sig, job
+
+      jobにシグナルsigを送る
+
+== カレントディレクトリ操作
+
+--- Shell#cd(path, &block)
+--- Shell#chdir
+
+      カレントディレクトリをpathにする. イテレータとして呼ばれたときには
+      ブロック実行中のみカレントディレクトリを変更する.
+
+--- Shell#pushd(path = nil, &block)
+--- Shell#pushdir
+
+      カレントディレクトリをディレクトリスタックにつみ, カレントディレク
+      トリをpathにする. pathが省略されたときには, カレントディレクトリと
+      ディレクトリスタックのトップを交換する. イテレータとして呼ばれたと
+      きには, ブロック実行中のみpushdする.
+
+--- Shell#popd
+--- Shell#popdir
+
+      ディレクトリスタックからポップし, それをカレントディレクトリにする.
+
+== ファイル/ディレクトリ操作
+
+--- Shell#foreach(path = nil, &block)
+
+      pathがファイルなら, File#foreach
+      pathがディレクトリなら, Dir#foreach
+
+--- Shell#open(path, mode)
+
+      pathがファイルなら, File#open
+      pathがディレクトリなら, Dir#open
+
+--- Shell#unlink(path)
+
+      pathがファイルなら, File#unlink
+      pathがディレクトリなら, Dir#unlink
+
+--- Shell#test(command, file1, file2)
+--- Shell#[command, file1, file2]
+
+      ファイルテスト関数testと同じ. 
+      例)
+          sh[?e, "foo"]
+          sh[:e, "foo"]
+          sh["e", "foo"]
+          sh[:exists?, "foo"]
+          sh["exists?", "foo"]
+
+--- Shell#mkdir(*path)
+
+      Dir.mkdirと同じ(複数可)
+
+--- Shell#rmdir(*path)
+
+      Dir.rmdirと同じ(複数可)
+
+== コマンド実行
+
+--- System#system(command, *opts)
+
+      commandを実行する.
+      例)
+        print sh.system("ls", "-l")
+        sh.system("ls", "-l") | sh.head > STDOUT
+
+--- System#rehash
+
+      リハッシュする
+
+--- Shell#transact &block
+
+      ブロック中ではshellをselfとして実行する.
+      例)
+        sh.transact{system("ls", "-l") | head > STDOUT}
+
+--- Shell#out(dev = STDOUT, &block)
+
+      transactを呼び出しその結果をdevに出力する.
+
+== 内部コマンド
+
+--- Shell#echo(*strings)
+--- Shell#cat(*files)
+--- Shell#glob(patten)
+--- Shell#tee(file)
+
+      これらは実行すると, それらを内容とするFilterオブジェクトを返します. 
+
+--- Filter#each &block
+
+      フィルタの一行ずつをblockに渡す.
+
+--- Filter#<(src)
+
+      srcをフィルタの入力とする. srcが, 文字列ならばファイルを, IOであれ
+      ばそれをそのまま入力とする.
+
+--- Filter#>(to)
+
+      srcをフィルタの出力とする. toが, 文字列ならばファイルに, IOであれ
+      ばそれをそのまま出力とする.
+
+--- Filter#>>(to)
+
+      srcをフィルタに追加する. toが, 文字列ならばファイルに, IOであれば
+      それをそのまま出力とする.
+
+--- Filter#|(filter)
+
+      パイプ結合
+
+--- Filter#+(filter)
+
+      filter1 + filter2 は filter1の出力の後, filter2の出力を行う.
+
+--- Filter#to_a
+--- Filter#to_s
+
+== 組込みコマンド
+
+--- Shell#atime(file)
+--- Shell#basename(file, *opt)
+--- Shell#chmod(mode, *files)
+--- Shell#chown(owner, group, *file)
+--- Shell#ctime(file)
+--- Shell#delete(*file)
+--- Shell#dirname(file)
+--- Shell#ftype(file)
+--- Shell#join(*file)
+--- Shell#link(file_from, file_to)
+--- Shell#lstat(file)
+--- Shell#mtime(file)
+--- Shell#readlink(file)
+--- Shell#rename(file_from, file_to)
+--- Shell#split(file)
+--- Shell#stat(file)
+--- Shell#symlink(file_from, file_to)
+--- Shell#truncate(file, length)
+--- Shell#utime(atime, mtime, *file)
+
+      これらはFileクラスにある同名のクラスメソッドと同じです.
+
+--- Shell#blockdev?(file)
+--- Shell#chardev?(file)
+--- Shell#directory?(file)
+--- Shell#executable?(file)
+--- Shell#executable_real?(file)
+--- Shell#exist?(file)/Shell#exists?(file)
+--- Shell#file?(file)
+--- Shell#grpowned?(file)
+--- Shell#owned?(file)
+--- Shell#pipe?(file)
+--- Shell#readable?(file)
+--- Shell#readable_real?(file)
+--- Shell#setgid?(file)
+--- Shell#setuid?(file)
+--- Shell#size(file)/Shell#size?(file)
+--- Shell#socket?(file)
+--- Shell#sticky?(file)
+--- Shell#symlink?(file)
+--- Shell#writable?(file)
+--- Shell#writable_real?(file)
+--- Shell#zero?(file)
+
+      これらはFileTestクラスにある同名のクラスメソッドと同じです.
+
+--- Shell#syscopy(filename_from, filename_to)
+--- Shell#copy(filename_from, filename_to)
+--- Shell#move(filename_from, filename_to)
+--- Shell#compare(filename_from, filename_to)
+--- Shell#safe_unlink(*filenames)
+--- Shell#makedirs(*filenames)
+--- Shell#install(filename_from, filename_to, mode)
+
+      これらはFileToolsクラスにある同名のクラスメソッドと同じです.
+
+      その他, 以下のものがエイリアスされています.
+
+--- Shell#cmp	<- Shell#compare
+--- Shell#mv	<- Shell#move
+--- Shell#cp	<- Shell#copy
+--- Shell#rm_f	<- Shell#safe_unlink
+--- Shell#mkpath	<- Shell#makedirs
+
+= サンプル
+
+== ex1
+
+  sh = Shell.cd("/tmp")
+  sh.mkdir "shell-test-1" unless sh.exists?("shell-test-1")
+  sh.cd("shell-test-1")
+  for dir in ["dir1", "dir3", "dir5"]
+    if !sh.exists?(dir)
+      sh.mkdir dir
+      sh.cd(dir) do
+	f = sh.open("tmpFile", "w")
+	f.print "TEST\n"
+	f.close
+      end
+      print sh.pwd
+    end
+  end
+
+== ex2
+
+  sh = Shell.cd("/tmp")
+  sh.transact do
+    mkdir "shell-test-1" unless exists?("shell-test-1")
+    cd("shell-test-1")
+    for dir in ["dir1", "dir3", "dir5"]
+      if !exists?(dir)
+	mkdir dir
+	cd(dir) do
+	  f = open("tmpFile", "w")
+	  f.print "TEST\n"
+	  f.close
+	end
+	print pwd
+      end
+    end
+  end
+
+== ex3
+
+  sh.cat("/etc/printcap") | sh.tee("tee1") > "tee2"
+  (sh.cat < "/etc/printcap") | sh.tee("tee11") > "tee12"
+  sh.cat("/etc/printcap") | sh.tee("tee1") >> "tee2"
+  (sh.cat < "/etc/printcap") | sh.tee("tee11") >> "tee12"
+
+== ex4
+
+  print sh.cat("/etc/passwd").head.collect{|l| l =~ /keiju/}
+
+=end
-- 
cgit v1.2.3