ruby how to escape command line args into a string via bat file

You may have tried to pass args to ruby via  bat file before, like

ruby -e “puts %*” # print out all the arguments

turns out this doesn’t work if you pass in an argument with backslashes, though [like \a\b\a -- it interpolates them as escaped strings]

To overcome this, create go.bat

ruby some_file.rb %*

then use ARGV within that file–it will no longer be escaped.

Enjoy.

random woes

E:/installs/ruby191p376/lib/ruby/1.9.1/timeout.rb:67: [BUG] The handle is invalid.
ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-mingw32]
– control frame ———-
c:0004 p:—- s:0010 b:0010 l:000009 d:000009 CFUNC  :sleep
c:0003 p:0012 s:0006 b:0006 l:000260 d:000005 BLOCK  E:/installs/ruby191p376/lib/ruby/1.9.1/timeout.rb:49
c:0002 p:—- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:—- s:0002 b:0002 l:000001 d:000001 TOP
—————————
– Ruby level backtrace information—————————————–
E:/installs/ruby191p376/lib/ruby/1.9.1/timeout.rb:49:in `sleep’
E:/installs/ruby191p376/lib/ruby/1.9.1/timeout.rb:49:in `block in timeout’

E:/installs/ruby191p376/lib/ruby/1.9.1/timeout.rb:67: [BUG] The handle is invalid.
ruby 1.9.1p376 (2009-12-07 revision 26041) [i386-mingw32]
– control frame ———-c:0004 p:—- s:0010 b:0010 l:000009 d:000009 CFUNC  :sleepc:0003 p:0012 s:0006 b:0006 l:000260 d:000005 BLOCK  E:/installs/ruby191p376/lib/ruby/1.9.1/timeout.rb:49c:0002 p:—- s:0004 b:0004 l:000003 d:000003 FINISHc:0001 p:—- s:0002 b:0002 l:000001 d:000001 TOP—————————– Ruby level backtrace information—————————————–E:/installs/ruby191p376/lib/ruby/1.9.1/timeout.rb:49:in `sleep’E:/installs/ruby191p376/lib/ruby/1.9.1/timeout.rb:49:in `block in timeout’

may have been related to

http://www.ruby-forum.com/topic/200692#new

ruby how to trace anytime an exception is raised (tracing exception creation)

you could do this by using set_trace_func (or it’s C wrappers)


require 'faster_rubygems'
require 'event_hook'

class Demo < EventHook   def self.process(*args)      # args => [64, #, :initialize, Exception]
   begin
     if args[1].is_a? Exception
       puts args.inspect
     end
   rescue
     # fantastically, this check fails within rails at times
   end
  end
end

Demo.start_hook

or you can just run ruby -d [$DEBUG = true] and it will do it for you automatically.

jruby woe

“c:/Program Files/jruby-1.4.0/bin/jruby.exe” -rubygems c:/Program Files/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake RUBYARCHDIR=”c:/Program Files/jruby-1.4.0/lib/ruby/gems/1.8/gems/faster_rubygems-0.1.0/lib” RUBYLIBDIR=”c:/Program Files/jruby-1.4.0/lib/ruby/gems/1.8/gems/faster_rubygems-0.1.0/lib”
Error opening script file: c:/Program (The system cannot find the file specified)

“c:/Program Files/jruby-1.4.0/bin/jruby.exe” -rubygems c:/Program Files/jruby-1.4.0/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake RUBYARCHDIR=”c:/Program Files/jruby-1.4.0/lib/ruby/gems/1.8/gems/faster_rubygems-0.1.0/lib” RUBYLIBDIR=”c:/Program Files/jruby-1.4.0/lib/ruby/gems/1.8/gems/faster_rubygems-0.1.0/lib”Error opening script file: c:/Program (The system cannot find the file specified)

meant “use jruby > 1.4, k? to avoid this bug in doze”

ruby 1.9 breakage

dense_ruby_to_ruby.cpp: In member function `size_t hashrb::operator()(VALUE) const’:
dense_ruby_to_ruby.cpp:70: error: `RBIGNUM_DIGITS’ was not declared in this scope
make: *** [dense_ruby_to_ruby.o] Error 1

dense_ruby_to_ruby.cpp: In member function `size_t hashrb::operator()(VALUE) const’:dense_ruby_to_ruby.cpp:70: error: `RBIGNUM_DIGITS’ was not declared in this scopemake: *** [dense_ruby_to_ruby.o] Error 1

meant “for 1.8, do”

#ifndef RBIGNUM_DIGITS

# define RBIGNUM_DIGITS(a) RBIGNUM(a)->digits

#endif

ruby-prof woe

gcc -I. -I. -IC:/ruby/lib/ruby/1.8/i386-mingw32 -I.  -g -O2   -c ruby_prof.c
ruby_prof.c: In function `get_method’:
ruby_prof.c:877: error: `node’ undeclared (first use in this function)
ruby_prof.c:877: error: (Each undeclared identifier is reported only once
ruby_prof.c:877: error: for each function it appears in.)
make: *** [ruby_prof.o] Error 1

gcc -I. -I. -IC:/ruby/lib/ruby/1.8/i386-mingw32 -I.  -g -O2   -c ruby_prof.cruby_prof.c: In function `get_method’:ruby_prof.c:877: error: `node’ undeclared (first use in this function)ruby_prof.c:877: error: (Each undeclared identifier is reported only onceruby_prof.c:877: error: for each function it appears in.)make: *** [ruby_prof.o] Error 1

meant “update your ruby prof version”

http://github.com/rdp/ruby-prof

ubuntu woe

sudo apt-get update yielded

Hit http://security.ubuntu.com karmic-security/multiverse Packages
Hit http://security.ubuntu.com karmic-security/multiverse Sources
56% [Waiting for headers]^C

which meant “go into syntaptic -> repositories and change your repository to be the main one not the country one”

ref:

http://www.ubuntugeek.com/how-to-select-fastest-mirror-in-ubuntu.html

http://forums.debian.net/viewtopic.php?f=10&t=46863