11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/vx/lib/shell/process.rb', line 11
def exec(*args, &block)
options = args.last.is_a?(Hash) ? args.pop : {}
command = args.first
home = options[:home] || "$HOME"
select_timeout = options.delete(:pool_interval) || Shell.pool_interval
timeout = Shell::Timeout.new options.delete(:timeout)
read_timeout = Shell::ReadTimeout.new options.delete(:read_timeout)
prefix = "/usr/bin/env - TERM=ansi USER=$USER HOME=#{home} SHELL=/bin/bash /bin/bash -l"
if command
command = "#{prefix} -c #{Shellwords.escape command}"
else
command = prefix
end
status = spawn_command_internal(command, options) do |r|
read_loop r, timeout, read_timeout, select_timeout, &block
end
compute_exit_code command, status, timeout, read_timeout
end
|