Method: DEBUGGER__.load_rc

Defined in:
lib/debug/session.rb

.load_rcObject



2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
# File 'lib/debug/session.rb', line 2302

def self.load_rc
  rc_file_paths = [
    [File.expand_path('~/.rdbgrc'), true],
    [File.expand_path('~/.rdbgrc.rb'), true],
    # ['./.rdbgrc', true], # disable because of security concern
  ]

  if (xdg_home = ENV["XDG_CONFIG_HOME"])
    rc_file_paths << [File.expand_path(File.join(xdg_home, "rdbg", "config")), true]
    rc_file_paths << [File.expand_path(File.join(xdg_home, "rdbg", "config.rb")), true]
  end

  rc_file_paths << [CONFIG[:init_script], false]

  rc_file_paths.each{|(path, rc)|
    next unless path
    next if rc && CONFIG[:no_rc] # ignore rc

    if File.file? path
      if path.end_with?('.rb')
        load path
      else
        ::DEBUGGER__::SESSION.add_preset_commands path, File.readlines(path)
      end
    elsif !rc
      warn "Not found: #{path}"
    end
  }

  # given debug commands
  if CONFIG[:commands]
    cmds = CONFIG[:commands].split(';;')
    ::DEBUGGER__::SESSION.add_preset_commands "commands", cmds, kick: false, continue: false
  end
end