16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/tinet/shell.rb', line 16
def sh(command, dry_run: false, print: false, continue: false)
if dry_run || print
Tinet.logger.info command
else
Tinet.logger.debug command
end
return ['', '', DummyStatus.new(true)] if dry_run
stdout, stderr, status = Open3.capture3(command)
if !status.success? && !continue
Tinet.logger.error "Command '#{command}' failed:"
Tinet.logger.error " #{stderr.chomp}" unless stderr.chomp.empty?
exit(status.to_i)
end
[stdout.chomp, stderr.chomp, status]
end
|