Skip to content

Commit b82db08

Browse files
committed
fix(base): fix shellescape to work on Windows
1 parent a675aaf commit b82db08

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lua/pathlib/base.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,12 +1005,16 @@ end
10051005
---@param special boolean|nil # If true, special items such as "!", "%", "#" and "<cword>" will be preceded by a backslash. The backslash will be removed again by the `:!` command. See `:h shellescape` for more details. The <NL> character is escaped.
10061006
---@return PathlibString
10071007
function Path:shell_string(special)
1008+
local quote = [["]]
10081009
local s = table.concat(
10091010
vim.tbl_map(function(t)
1010-
return vim.fn.shellescape(t, special)
1011+
local escape = vim.fn.shellescape(t, special)
1012+
quote = escape:sub(1, 1)
1013+
return escape:sub(2, #escape - 1)
10111014
end, self._raw_paths),
10121015
"/"
10131016
)
1017+
s = quote .. s .. quote
10141018
if self._drive_name:len() > 0 then
10151019
s = self._drive_name .. s
10161020
end

0 commit comments

Comments
 (0)