8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/hfam/commands/source.rb', line 8
def run(command)
src = command[1]
::HFAM::Logger.error("No such file or directory: #{src}") and return unless File.exist? src
file = src.split('/').last
file = ::FileUtils.hidden_file?(file) ? file : ".#{file}"
dest = "#{command[2]}/#{file}"
real_shell_path = ::Pathname.new(ENV['SHELL']).realpath.to_s
cmd = real_shell_path.split('/').last == "dash" ? '.' : "source"
(cmd = "#{real_shell_path} -c '#{cmd} #{dest}'") && result = `#{cmd}`
::HFAM::Logger.success(result)
::HFAM::Logger.success("Source: #{cmd}")
rescue ::Errno::EACCES => e
l::HFAM::Logger.error("Unable to source #{dest} (Permission Denied)")
end
|