I finally able to fix the problem
[...]
The problem is in system("more < file"). I try similar thing with irb
irb(main):001:0> system "more < c:\autoexec.bat"
File not found
=> true
Silly me, I forgot to escape '\'.
If i use system("more < c:\\autoexec.bat") everything will work as
expected.
The actual problem is:
1. The path is UNIX style which must be converted to DOS style before
passed on to external program.
2. For some reason in Windows ME Tempfile is working intermittenly.
As a workaround I unlink it after use and it always works.
Here's the patch
···
On Mon, Jul 26, 2004 at 07:08:57PM +0900, Zakaria wrote:
--- ri_display.rb.orig 2004-03-25 22:31:10.000000000 +0700
+++ ri_display.rb 2004-07-26 22:34:26.000000000 +0700
@@ -210,7 +210,8 @@
require 'tempfile'
@save_stdout = STDOUT.clone
- STDOUT.reopen(Tempfile.new("ri_"))
+ @tempfile = Tempfile.new("ri_")
+ STDOUT.reopen(@tempfile)
end
end
@@ -219,6 +220,7 @@
def page_output
unless @options.use_stdout
path = STDOUT.path
+ path = path.gsub(%{/}, '\\\\') if Config::CONFIG['arch'] =~ /mswin/
STDOUT.reopen(@save_stdout)
@save_stdout = nil
paged = false
@@ -232,6 +234,16 @@
@options.use_stdout = true
puts File.read(path)
end
+
+ retryctr = 0
+ begin
+ retryctr += 1
+ @tempfile.unlink
+ rescue
+ sleep 0.1
+ retry if retryctr < 10
+ end
+ @tempfile = nil
end
end
=============================================================================
Dave, is the patch OK?
Wassallam,
-- Zakaria
z4k4ri4@bigfoot.com Yahoo!: z4k4ri4
http://zakaria.is-a-geek.org
http://pemula.linux.or.id