From: Carlos Date: 2001-09-25T20:14:00+09:00 Subject: [ruby-talk:21666] Threads and $SAFE I'm trying to load some scripts that interact with my main script, but I don't want them to do unsafe operations, or puts, etc... First question: according to the Ruby Book, this should work. Why doesn't it? Thread.new { $SAFE=4 load("x.rb", true) # I should be able to load wrapped scripts (?) }.join $ ruby loader.rb loader.rb:3:in `load': Insecure operation `load' at level 4 (SecurityError) from loader.rb:1:in `join' from loader.rb:1 And the second and maybe critical question: Can I change the $SAFE level in some parts of the script? I want to do unsafe operations at the loaded script's demand, but only under my control. Something like that: def callback(x); puts "called with #{x}"; end Thread.new { $SAFE=4 callback(1) }.join Of course it doesn't work, because `callback' is called in the current thread. But is there a way to do it? Maybe I can declare some portions of code as safe, before changing the value of $SAFE (?).