def run(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
options = BUILTIN_DEFAULT_OPTIONS.merge(@default_options).merge(options)
options[:stdin] ||= ""
if !options[:allowed_exitstatus].respond_to?(:include?)
options[:allowed_exitstatus] = Array(options[:allowed_exitstatus])
end
streamed = compute_streamed(options)
streams = build_streams(options, streamed)
commands = build_commands(args)
recorder = build_recorder(options)
recorder.record_commands(commands)
pid, pipes = fork_commands(commands, options)
select_loop(streams, pipes, recorder)
_pid, status = Process.wait2(pid)
begin
check_errors(commands, status, streams, streamed, options)
ensure
recorder.record_status(status)
end
build_result(streams, status, options)
end