From: Samu Voutilainen Date: 2009-03-25T03:45:15+09:00 Subject: [ruby-core:23016] [Bug #1314] CGI doesn૑t properly handle empty arguments Bug #1314: CGI doesn���t properly handle empty arguments http://redmine.ruby-lang.org/issues/show/1314 Author: Samu Voutilainen Status: Open, Priority: Normal ruby -v: ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux] In case you are trying to initialise with CGI.new, on non-interactive ���terminal���, Ruby fails with: /usr/lib64/ruby/1.8/cgi.rb:1092:in `readlines': Invalid argument (Errno::EINVAL) from /usr/lib64/ruby/1.8/cgi.rb:1092:in `read_from_cmdline' from /usr/lib64/ruby/1.8/cgi.rb:1129:in `initialize_query' from /usr/lib64/ruby/1.8/cgi.rb:2281:in `initialize' I fixed it by modifying read_from_cmdline a bit: # offline mode. read name=value pairs on standard input. def read_from_cmdline require "shellwords" string = unless ARGV.empty? ARGV.join(' ') else if STDIN.tty? STDERR.print( %|(offline mode: enter name=value pairs on standard input)\n| ) end array = nil begin readlines rescue end if not array.nil? array.join(' ').gsub(/\n/n, '') else "" end end.gsub(/\\=/n, '%3D').gsub(/\\&/n, '%26') words = Shellwords.shellwords(string) if words.find{|x| /=/n.match(x) } words.join('&') else words.join('+') end end Sorry that it isn���t patch, I just edited cgi.rb found from my system... ---------------------------------------- http://redmine.ruby-lang.org