summaryrefslogtreecommitdiff
path: root/lib/chef/shell.rb
diff options
context:
space:
mode:
authorKartik Null Cating-Subramanian <ksubramanian@chef.io>2015-03-17 18:47:08 -0400
committerKartik Null Cating-Subramanian <ksubramanian@chef.io>2015-03-20 11:22:30 -0400
commit8adb5e38a31f47d84fcac6c825b5bd9279ba6aac (patch)
tree55052f72db7172064e5bb8b77869598a0ebc9b03 /lib/chef/shell.rb
parent55d9ee24a8b2b14af415a36ff3c60b737dd84027 (diff)
downloadchef-8adb5e38a31f47d84fcac6c825b5bd9279ba6aac.tar.gz
Modify accesses to HOME to use path_helper instead.
Diffstat (limited to 'lib/chef/shell.rb')
-rw-r--r--lib/chef/shell.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/chef/shell.rb b/lib/chef/shell.rb
index fed32b3795..ee4fe78808 100644
--- a/lib/chef/shell.rb
+++ b/lib/chef/shell.rb
@@ -29,6 +29,7 @@ require 'chef/config_fetcher'
require 'chef/shell/shell_session'
require 'chef/shell/ext'
require 'chef/json_compat'
+require 'chef/util/path_helper'
# = Shell
# Shell is Chef in an IRB session. Shell can interact with a Chef server via the
@@ -101,7 +102,7 @@ module Shell
end
def self.configure_irb
- irb_conf[:HISTORY_FILE] = "~/.chef/chef_shell_history"
+ irb_conf[:HISTORY_FILE] = Chef::Util::PathHelper.home(".chef", "chef_shell_history")
irb_conf[:SAVE_HISTORY] = 1000
irb_conf[:IRB_RC] = lambda do |conf|
@@ -295,18 +296,19 @@ FOOTER
private
def config_file_for_shell_mode(environment)
+ dot_chef_dir = Chef::Util::PathHelper.home('.chef')
if config[:config_file]
config[:config_file]
- elsif environment && ENV['HOME']
+ elsif environment
Shell.env = environment
- config_file_to_try = ::File.join(ENV['HOME'], '.chef', environment, 'chef_shell.rb')
+ config_file_to_try = ::File.join(dot_chef_dir, environment, 'chef_shell.rb')
unless ::File.exist?(config_file_to_try)
puts "could not find chef-shell config for environment #{environment} at #{config_file_to_try}"
exit 1
end
config_file_to_try
- elsif ENV['HOME'] && ::File.exist?(File.join(ENV['HOME'], '.chef', 'chef_shell.rb'))
- File.join(ENV['HOME'], '.chef', 'chef_shell.rb')
+ elsif dot_chef_dir && ::File.exist?(File.join(dot_chef_dir, 'chef_shell.rb'))
+ File.join(dot_chef_dir, 'chef_shell.rb')
elsif config[:solo]
Chef::Config.platform_specific_path("/etc/chef/solo.rb")
elsif config[:client]