ocra icon indicating copy to clipboard operation
ocra copied to clipboard

ocra giving trouble with File.open when command line argument is used

Open derekomartin opened this issue 9 years ago • 2 comments

Here is my problem:

I have a file "file.txt", contents: This is a test file.

I have a test script "test.rb", contents: astr = ARGV[0] File.open(astr,"r").each { |line| puts line }

If I type "ruby test.rb file.txt" I get: This is a test file.

If I type "ocra test.rb" I get: === Loading script to check dependencies C:/PATHTOSCRIPT/test.rb:2:in initialize': no implicit conversion of nil into String (TypeError) from C:/PATHTOSCRIPT/test.rb:2:inopen' from C:/PATHTOSCRIPT/test.rb:2:in <top (required)>' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/ocra-1.3.5/bin/ocra:1185:inload' from C:/Ruby22/lib/ruby/gems/2.2.0/gems/ocra-1.3.5/bin/ocra:1185:in <top (required)>' from C:/Ruby22/bin/ocra:23:inload' from C:/Ruby22/bin/ocra:23:in `

'

What am I doing wrong?

derekomartin avatar Apr 29 '15 17:04 derekomartin

Oh yeah. This is using ruby 2.2.2 on Windows 7 x64

derekomartin avatar Apr 29 '15 17:04 derekomartin

Clearly ARGV[0] is nil in the second case since nothing was passed.

ptyagi16 avatar Jul 28 '15 06:07 ptyagi16