If the stack trace is empty, we can start execution right and left. I do not know if it has been used traditionally or unconventionally since I have been in Ruby for about a week.
if caller.length == 0
Proof of concept:
file: test.rb
#!/usr/bin/ruby if caller.length == 0 puts "Main script" end puts "Test"
file: shmest.rb
#!/usr/bin/ruby -I . require 'test.rb' puts "Shmest"
Using:
$ ./shmest.rb Test Shmest $ ./test.rb Main script Test
uKolka Oct 14 '13 at 22:55 2013-10-14 22:55
source share