From 80684e9c09338adcbbf1bc4827938f28178e84c1 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 23 Jun 2010 08:25:12 +0000 Subject: * ext/pty: moved documents and samples to the appropriate places. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/pty/README | 84 ------------------------------------------- ext/pty/README.expect | 22 ------------ ext/pty/README.expect.ja | 21 ----------- ext/pty/README.ja | 76 --------------------------------------- ext/pty/expect_sample.rb | 48 ------------------------- ext/pty/script.rb | 37 ------------------- ext/pty/shl.rb | 92 ------------------------------------------------ 7 files changed, 380 deletions(-) delete mode 100644 ext/pty/README delete mode 100644 ext/pty/README.expect delete mode 100644 ext/pty/README.expect.ja delete mode 100644 ext/pty/README.ja delete mode 100644 ext/pty/expect_sample.rb delete mode 100644 ext/pty/script.rb delete mode 100644 ext/pty/shl.rb (limited to 'ext') diff --git a/ext/pty/README b/ext/pty/README deleted file mode 100644 index d6368f3758..0000000000 --- a/ext/pty/README +++ /dev/null @@ -1,84 +0,0 @@ -pty extension version 0.3 by A.ito - -1. Introduction - -This extension module adds ruby a functionality to execute an -arbitrary command through pseudo tty (pty). - -2. Install - -Follow the instruction below. - -(1) Execute - - ruby extconf.rb - - then Makefile is generated. - -(3) Do make; make install. - -3. What you can do - -This extension module defines a module named PTY, which contains -following module fungtions: - - getpty(command) - spawn(command) - - This function reserves a pty, executes command over the pty - and returns an array. The return value is an array with three - elements. The first element in the array is for reading and the - second for writing. The third element is the process ID of the - child process. If this function is called with an iterator block, - the array is passed to the block as block parameters, and the - function itself returns nil. - - When the child process is suspended or finished, an exception is - raised. If this function is called with an iterator block, - exception is raised only within the block. Child process - monitor is terminated on block exit. - - protect_signal - reset_signal - - These functions are obsolete in this version of pty. - - PTY.open - - Allocates a pty (pseudo-terminal). - - It returns an array which contains an IO object and a File object. - The former is the master of the pty. - The latter is the slave of the pty. - - If a block is given, it yields the array instead of return. - The value of the block is returned. - master_io and slave_file is closed when return if they are not closed. - - PTY.check(pid[, raise=false]) - - checks the status of the child process specified by pid, and - returns nil if the process is still alive and active. - Otherwise, returns Process::Status about the process if raise is - false, or PTY::ChildExited exception is raised. - -4. License - -(C) Copyright 1998 by Akinori Ito. - -This software may be redistributed freely for this purpose, in full -or in part, provided that this entire copyright notice is included -on any copies of this software and applications and derivations thereof. - -This software is provided on an "as is" basis, without warranty of any -kind, either expressed or implied, as to any matter including, but not -limited to warranty of fitness of purpose, or merchantability, or -results obtained from use of this software. - -5. Bug report - -Please feel free to send E-mail to - - aito@ei5sun.yz.yamagata-u.ac.jp - -for any bug report, opinion, contribution, etc. diff --git a/ext/pty/README.expect b/ext/pty/README.expect deleted file mode 100644 index fddbb6fdad..0000000000 --- a/ext/pty/README.expect +++ /dev/null @@ -1,22 +0,0 @@ - README for expect - by A. Ito, 28 October, 1998 - - Expect library adds IO class a method called expect(), which -does similar act to tcl's expect extension. - -The usage of the method is: - - IO#expect(pattern,timeout=9999999) - -where `pattern' is an instance of String or Regexp and `timeout' -is Fixnum, which can be omitted. - When the method is called without block, it waits until the -input which matches the pattern is obtained from the IO or the time -specified as the timeout passes. When the pattern is obtained from the -IO, the method returns an array. The first element of the array is the -entire string obtained from the IO until the pattern matches. The -following elements indicates the specific pattern which matched to the -anchor in the regular expression. If the method ends because of -timeout, it returns nil. - When the method is called with block, the array is passed as -the block parameter. diff --git a/ext/pty/README.expect.ja b/ext/pty/README.expect.ja deleted file mode 100644 index db84695ee5..0000000000 --- a/ext/pty/README.expect.ja +++ /dev/null @@ -1,21 +0,0 @@ - README for expect - by A. Ito, 28 October, 1998 - - Expectライブラリは,tcl の expect パッケージと似たような機能を -IOクラスに追加します. - - 追加されるメソッドの使い方は次の通りです. - - IO#expect(pattern,timeout=9999999) - -pattern は String か Regexp のインスタンス,timeout は Fixnum -のインスタンスです.timeout は省略できます. - このメソッドがブロックなしで呼ばれた場合,まずレシーバである -IOオブジェクトから pattern にマッチするパターンが読みこまれる -まで待ちます.パターンが得られたら,そのパターンに関する配列を -返します.配列の最初の要素は,pattern にマッチするまでに読みこ -まれた内容の文字列です.2番目以降の要素は,pattern の正規表現 -の中にアンカーがあった場合に,そのアンカーにマッチする部分です. -もしタイムアウトが起きた場合は,このメソッドはnilを返します. - このメソッドがブロック付きで呼ばれた場合には,マッチした要素の -配列がブロック引数として渡され,ブロックが評価されます. diff --git a/ext/pty/README.ja b/ext/pty/README.ja deleted file mode 100644 index ca2a01442a..0000000000 --- a/ext/pty/README.ja +++ /dev/null @@ -1,76 +0,0 @@ -pty 拡張モジュール version 0.3 by A.ito - -1. はじめに - -この拡張モジュールは,仮想tty (pty) を通して適当なコマンドを -実行する機能を ruby に提供します. - -2. インストール - -次のようにしてインストールしてください. - -(1) ruby extconf.rb - - を実行すると Makefile が生成されます. - -(2) make; make install を実行してください. - -3. 何ができるか - -この拡張モジュールは,PTY というモジュールを定義します.その中 -には,次のようなモジュール関数が含まれています. - - getpty(command) - spawn(command) - - この関数は,仮想ttyを確保し,指定されたコマンドをその仮想tty - の向こうで実行し,配列を返します.戻り値は3つの要素からなる - 配列です.最初の要素は仮想ttyから読み出すためのIOオブジェクト, - 2番目は書きこむためのIOオブジェクト,3番目は子プロセスのプロ - セスIDです.この関数がイテレータとして呼ばれた場合,これらの - 要素はブロックパラメータとして渡され,関数自体はnilを返します. - - 子プロセスが終了したり停止した場合には,例外が発生します.この関 - 数がブロックパラメータ付きで呼ばれた場合には,そのブロックの中で - のみ例外が発生します.子プロセスをモニターしているスレッドはブロッ - クを抜けるときに終了します. - - protect_signal - reset_signal - - 廃止予定です. - - PTY.open - - 仮想ttyを確保し,マスター側に対応するIOオブジェクトとスレーブ側に - 対応するFileオブジェクトの配列を返します.ブロック付きで呼び出さ - れた場合は,これらの要素はブロックパラメータとして渡され,ブロッ - クから返された結果を返します.また、このマスターIOとスレーブFile - は、ブロックを抜けるときにクローズ済みでなければクローズされます. - - PTY.check(pid[, raise=false]) - - pidで指定された子プロセスの状態をチェックし,実行中であればnilを - 返します.終了しているか停止している場合、第二引数が偽であれば、 - 対応するProcess::Statusオブジェクトを返します。真であれば - PTY::ChildExited例外が発生します. - -4. 利用について - -伊藤彰則が著作権を保有します. - -ソースプログラムまたはドキュメントに元の著作権表示が改変されずに -表示されている場合に限り,誰でも,このソフトウェアを無償かつ著作 -権者に無断で利用・配布・改変できます.利用目的は限定されていませ -ん. - -このプログラムの利用・配布その他このプログラムに関係する行為によ -って生じたいかなる損害に対しても,作者は一切責任を負いません. - -5. バグ報告等 - -バグレポートは歓迎します. - - aito@ei5sun.yz.yamagata-u.ac.jp - -まで電子メールでバグレポートをお送りください. diff --git a/ext/pty/expect_sample.rb b/ext/pty/expect_sample.rb deleted file mode 100644 index d3b072b83c..0000000000 --- a/ext/pty/expect_sample.rb +++ /dev/null @@ -1,48 +0,0 @@ -# -# sample program of expect.rb -# -# by A. Ito -# -# This program reports the latest version of ruby interpreter -# by connecting to ftp server at ruby-lang.org. -# -require 'pty' -require 'expect' - -fnames = [] -PTY.spawn("ftp ftp.ruby-lang.org") do |r_f,w_f,pid| - w_f.sync = true - - $expect_verbose = false - - if !ENV['USER'].nil? - username = ENV['USER'] - elsif !ENV['LOGNAME'].nil? - username = ENV['LOGNAME'] - else - username = 'guest' - end - - r_f.expect(/^(Name).*: |(word):|> /) do - w_f.puts($1 ? "ftp" : $2 ? "#{username}@" : "cd pub/ruby") - end - r_f.expect("> ") do - w_f.print "dir\n" - end - - r_f.expect(/[^\-]> /) do |output| - for x in output[0].split("\n") - if x =~ /(ruby.*?\.tar\.gz)/ then - fnames.push $1 - end - end - end - begin - w_f.print "quit\n" - rescue - end -end - -print "The latest ruby interpreter is " -print fnames.sort.pop -print "\n" diff --git a/ext/pty/script.rb b/ext/pty/script.rb deleted file mode 100644 index 903a6f75bd..0000000000 --- a/ext/pty/script.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'pty' - -if ARGV.size == 0 then - ofile = "typescript" -else - ofile = ARGV[0] -end - -logfile = File.open(ofile,"a") - -system "stty -echo raw lnext ^_" - -PTY.spawn("/bin/csh") do |r_pty,w_pty,pid| - - Thread.new do - while true - w_pty.print STDIN.getc.chr - w_pty.flush - end - end - - begin - while true - c = r_pty.sysread(512) - break if c.nil? - print c - STDOUT.flush - logfile.print c - end - rescue - # print $@,':',$!,"\n" - logfile.close - end -end - -system "stty echo -raw lnext ^v" - diff --git a/ext/pty/shl.rb b/ext/pty/shl.rb deleted file mode 100644 index cdaf8d7398..0000000000 --- a/ext/pty/shl.rb +++ /dev/null @@ -1,92 +0,0 @@ -# -# old-fashioned 'shl' like program -# by A. Ito -# -# commands: -# c creates new shell -# C-z suspends shell -# p lists all shell -# 0,1,... choose shell -# q quit - -require 'pty' - -$shells = [] -$n_shells = 0 - -$r_pty = nil -$w_pty = nil - -def writer - system "stty -echo raw" - begin - while true - c = STDIN.getc - if c == 26 then # C-z - $reader.raise(nil) - return 'Suspend' - end - $w_pty.print c.chr - $w_pty.flush - end - rescue - $reader.raise(nil) - return 'Exit' - ensure - system "stty echo -raw" - end -end - -$reader = Thread.new { - while true - begin - next if $r_pty.nil? - c = $r_pty.getc - if c.nil? then - Thread.stop - end - print c.chr - STDOUT.flush - rescue - Thread.stop - end - end -} - -# $reader.raise(nil) - - -while true - print ">> " - STDOUT.flush - case gets - when /^c/i - $shells[$n_shells] = PTY.spawn("/bin/csh") - $r_pty,$w_pty = $shells[$n_shells] - $n_shells += 1 - $reader.run - if writer == 'Exit' - $n_shells -= 1 - $shells[$n_shells] = nil - end - when /^p/i - for i in 0..$n_shells - unless $shells[i].nil? - print i,"\n" - end - end - when /^([0-9]+)/ - n = $1.to_i - if $shells[n].nil? - print "\##{i} doesn't exist\n" - else - $r_pty,$w_pty = $shells[n] - $reader.run - if writer == 'Exit' then - $shells[n] = nil - end - end - when /^q/i - exit - end -end -- cgit v1.2.3