local M = {} function M.textreg(s) return { lines = { tostring(s) }, type = 'v' } end function M.readonly(getter) return { read = function() return M.textreg(getter()) end, write = function() return false end, readonly = true, } end function M.path(path) return vim.fn.expand(path) end function M.shell_quote(s) return "'" .. s:gsub("'", "'\\''") .. "'" end function M.system(argv, input, label) local result = vim.system(argv, { text = false, stdin = input }):wait() if result.code ~= 0 then error((label or argv[1]) .. ': ' .. (result.stderr or ('exit status ' .. result.code))) end return result.stdout or '' end return M