[前][次][番号順一覧][スレッド一覧]

ruby-changes:45455

From: kazu <ko1@a...>
Date: Sat, 4 Feb 2017 15:49:07 +0900 (JST)
Subject: [ruby-changes:45455] kazu:r57528 (trunk): sample/pty/expect_sample.rb: Update sample

kazu	2017-02-04 15:49:04 +0900 (Sat, 04 Feb 2017)

  New Revision: 57528

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57528

  Log:
    sample/pty/expect_sample.rb: Update sample
    
    * Fix regexp capture scope bug.
    * Specify frozen_string_literal: true.
    * Use passive mode.

  Modified files:
    trunk/sample/pty/expect_sample.rb
Index: sample/pty/expect_sample.rb
===================================================================
--- sample/pty/expect_sample.rb	(revision 57527)
+++ sample/pty/expect_sample.rb	(revision 57528)
@@ -1,3 +1,4 @@ https://github.com/ruby/ruby/blob/trunk/sample/pty/expect_sample.rb#L1
+# frozen_string_literal: true
 #
 # sample program of expect.rb
 #
@@ -23,8 +24,17 @@ PTY.spawn("ftp ftp.ruby-lang.org") do |r https://github.com/ruby/ruby/blob/trunk/sample/pty/expect_sample.rb#L24
     username = 'guest'
   end
 
-  r_f.expect(/^(Name).*: |(word):|> /) do
-    w_f.puts($1 ? "ftp" : $2 ? "#{username}@" : "cd pub/ruby")
+  r_f.expect(/^Name.*: /) do
+    w_f.puts("ftp")
+  end
+  r_f.expect(/word:/) do
+    w_f.puts("#{username}@")
+  end
+  r_f.expect(/> /) do
+    w_f.puts("cd pub/ruby")
+  end
+  r_f.expect("> ") do
+    w_f.print "pass\n"
   end
   r_f.expect("> ") do
     w_f.print "dir\n"

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]