lib/hash_delegator.rb in markdown_exec-2.0.3 vs lib/hash_delegator.rb in markdown_exec-2.0.3.1

- old
+ new

@@ -6,12 +6,14 @@ require 'English' require 'clipboard' require 'fileutils' require 'open3' require 'optparse' +require 'ostruct' require 'set' require 'shellwords' +require 'tempfile' require 'tmpdir' require 'tty-prompt' require 'yaml' require_relative 'array' @@ -1140,22 +1142,21 @@ end end def link_block_data_eval(link_state, code_lines, selected, link_block_data, block_source:) all_code = HashDelegator.code_merge(link_state&.inherited_lines, code_lines) + cmd = "#{@delegate_object[:shell]} #{file.path}" + output_lines = [] Tempfile.open do |file| file.write(all_code.join("\n")) file.rewind if link_block_data.fetch(LinkKeys::Exec, false) @run_state.files = Hash.new([]) - output_lines = [] - Open3.popen3( - "#{@delegate_object[:shell]} #{file.path}" - ) do |stdin, stdout, stderr, _exec_thr| + Open3.popen3(cmd) do |stdin, stdout, stderr, _exec_thr| handle_stream(stream: stdout, file_type: ExecutionStreams::StdOut) do |line| output_lines.push(line) end handle_stream(stream: stderr, file_type: ExecutionStreams::StdErr) do |line| output_lines.push(line) @@ -1179,11 +1180,10 @@ scan1: @delegate_object.fetch(:output_assignment_match, nil), format1: @delegate_object.fetch(:output_assignment_format, nil) ) else - # output_lines = `#{all_code.join("\n")}`.split("\n") - output_lines = `#{@delegate_object[:shell]} #{file.path}`.split("\n") + output_lines = `#{cmd}`.split("\n") end end HashDelegator.error_handler('all_code eval output_lines is nil', { abort: true }) unless output_lines