def with_tempfile(fname = nil, &_block)
      Tempfile.open("tmp") do |f|
        yield f.path, f.path.shellescape
        FileUtils.cp(f.path, fname) unless fname.nil?
      end
    end
def with_tempfile(fname = nil, &_block)
      Tempfile.open("tmp") do |f|
        yield f.path, f.path.shellescape
        FileUtils.cp(f.path, fname) unless fname.nil?
      end
    end
Create and manage a temp file, replacing `fname` with the temp file, if `fname` is provided.