If I assign a new value to $0, I find it is truncated.
$ cat test-dollar0.rb
str = “/foo” * 20
$0 = str
$ ruby test-dollar0.rb
$ ln -s test-dollar0.rb td.rb
$ ruby td.rb
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