From: Robert Klemme Date: 2009-05-16T22:45:04+09:00 Subject: Re: $0 is truncated On 16.05.2009 15:03, Brian Candler wrote: > If I assign a new value to $0, I find it is truncated. > > $ cat test-dollar0.rb > puts $0 > str = "/foo" * 20 > puts str.size > $0 = str > puts $0 > puts $0.size > > $ ruby test-dollar0.rb > test-dollar0.rb > 80 > /foo/foo/foo/foo/foo > 20 > > $ ln -s test-dollar0.rb td.rb > $ ruby td.rb > td.rb > 80 > /foo/foo/f > 10 > > In 1.8.6 I can get around this by $0.replace('....'), which sets $0 to > any string I like. However this doesn't work in 1.8.7 or 1.9, because in > those versions $0 is a frozen string. > > Any suggestions for how to fix this? The application is that I want to > start launcher program A, which in turn loads program B. Program B may > be a Test::Unit test suite, and Test::Unit gets the test suite name from > $0. So I either end up with the test suite having the name of program A > (which is wrong), or a truncated version of program B's name (which is > also wrong) Modifying $0 seems a bit hackish to me. Can't you just set the name explicitly? Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/