mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Don't load/save history or load rc if we can't find home.
Fixes: #477. Signed-off-by: Jordon Bedwell <jordon@envygeeks.com>
This commit is contained in:
parent
4e8a436460
commit
3f9741b628
2 changed files with 18 additions and 1 deletions
|
@ -249,7 +249,13 @@ class Pry
|
|||
config.history ||= OpenStruct.new
|
||||
config.history.should_save = true
|
||||
config.history.should_load = true
|
||||
config.history.file = File.expand_path("~/.pry_history")
|
||||
config.history.file = File.expand_path("~/.pry_history") rescue nil
|
||||
|
||||
if config.history.file.nil?
|
||||
config.should_load_rc = false
|
||||
config.history.should_save = false
|
||||
config.history.should_load = false
|
||||
end
|
||||
|
||||
config.control_d_handler = DEFAULT_CONTROL_D_HANDLER
|
||||
|
||||
|
|
|
@ -296,6 +296,17 @@ describe Pry do
|
|||
Object.remove_const(:TEST_RC)
|
||||
end
|
||||
|
||||
it "should not load the pryrc if it cannot expand ENV[HOME]" do
|
||||
old_home = ENV['HOME']
|
||||
old_rc = Pry.config.should_load_rc
|
||||
ENV['HOME'] = nil
|
||||
Pry.config.should_load_rc = true
|
||||
lambda { Pry.start(self, :input => StringIO.new("exit-all\n"), :output => Pry::NullOutput) }.should.not.raise
|
||||
|
||||
ENV['HOME'] = old_home
|
||||
Pry.config.should_load_rc = old_rc
|
||||
end
|
||||
|
||||
it "should not run the rc file at all if Pry.config.should_load_rc is false" do
|
||||
Pry.config.should_load_rc = false
|
||||
Pry.start(self, :input => StringIO.new("exit-all\n"), :output => Pry::NullOutput)
|
||||
|
|
Loading…
Add table
Reference in a new issue