28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/mini_magick/shell.rb', line 28
def execute(command, stdin: "", timeout: MiniMagick.timeout)
env = MiniMagick.restricted_env ? ENV.to_h.slice("HOME", "PATH", "LANG") : {}
env.merge!(MiniMagick.cli_env)
env["MAGICK_TIME_LIMIT"] = timeout.to_s if timeout
stdout, stderr, status = log(command.join(" ")) do
Open3.capture3(env, *command, stdin_data: stdin, unsetenv_others: MiniMagick.restricted_env)
end
[stdout, stderr, status&.exitstatus]
rescue Errno::ENOENT, IOError
["", "executable not found: \"#{command.first}\"", 127]
end
|