From: greg weber Date: 2006-11-27T10:55:14+09:00 Subject: Re: Truncating string set on $0 ------=_Part_111853_6400625.1164592511359 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Using a launcher will also break RDoc::Usage() in usage.rb because it relies on the first position of caller(). This is also arguably a bug. I have patched this (attached) by adding an option to pass in a file because this could be useful in other ways, but this could also be fixed by properly examining caller(). -Greg Weber On 11/26/06, Joao Pedrosa wrote: > Hi, > > I have a "pre-ruby-launcher", which loads some environment > variables and launches the other script. That is, the first script > is just temporary, while the second script is the final (main) one. > > To make it work transparently, I used to set the $0 variable to > the filename of the second script, and everything, for months, > ran smoothly. That is, until today. Today I noticed that a large > filename string could be truncated, and it seems that the length > depends on the initial command for launching Ruby. > > For example, running this script: > s = 'a' > 100.times{|n| > z = s * n > $0 = z > if z.size != $0.size > p n > exit > end > } > > Prints: > dewd@corvina:~/t_/tempo$ ruby first_file.rb > 19 > > It stops at the length of "ruby first_file.rb". > > Thankfully, despite this issue, things have worked ok > until today. > > I'm not sure you want to fix this or whether this is > could be considered a problem at all. I can circumvent > this issue at least for my latest usage of this. > > Cheers, > Joao > > ------=_Part_111853_6400625.1164592511359 Content-Type: application/octet-stream; name=usage.diff Content-Transfer-Encoding: base64 X-Attachment-Id: f_ev085yeq Content-Disposition: attachment; filename="usage.diff" LS0tIC4vcnVieS9saWIvcmRvYy91c2FnZS5yYgkyMDA2LTAxLTI3IDE2OjU2OjExLjAwMDAwMDAw MCAtMDYwMAorKysgL21udC9kL3NmL3NjcmlwdC90cnVuay91bml4L2xpYi9ydWJ5L3Jkb2MvdXNh Z2UucmIJMjAwNi0xMS0yNiAxOTozNTowMi41NjI1MDAwMDAgLTA2MDAKQEAgLTk2LDcgKzk2LDEz IEBACiAKICAgIyBEaXNwbGF5IHVzYWdlCiAgIGRlZiBSRG9jLnVzYWdlX25vX2V4aXQoKmFyZ3Mp Ci0gICAgbWFpbl9wcm9ncmFtX2ZpbGUgPSBjYWxsZXJbLTFdLnN1YigvOlxkKyQvLCAnJykKKyAg ICBtYWluX3Byb2dyYW1fZmlsZSA9CisgICAgaWYgSGFzaCA9PT0gYXJnc1swXQorICAgICAgYXJn cy5zaGlmdFs6ZmlsZV0gfHwgcmFpc2UgQXJndW1lbnRFcnJvciwgIm5vIGZpbGUgc3BlY2lmaWVk IgorICAgIGVsc2UKKyAgICAgIGNhbGxlclstMV0uc3ViKC86XGQrJC8sICcnKQorICAgIGVuZAor CiAgICAgY29tbWVudCA9IEZpbGUub3BlbihtYWluX3Byb2dyYW1fZmlsZSkgZG8gfGZpbGV8CiAg ICAgICBmaW5kX2NvbW1lbnQoZmlsZSkKICAgICBlbmQK ------=_Part_111853_6400625.1164592511359--