Skip to content

Commit f288bed

Browse files
committed
Restore cmd.exe wrapping for mklink and dir on Windows
`mklink` and `dir` are cmd.exe built-ins with no standalone executable, so removing the cmd.exe wrapper for all Subprocess calls broke FileUtils.symlink (and left FileUtils.symlink?/readlink working only by accident, since `dir` happens to be on MRI's hardcoded list of legacy cmd.exe built-ins that Process.spawn falls back to). Unlike the removed general-purpose wrapper, this passes cmd.exe, /c, and the command as separate argv elements rather than joining them into one pre-escaped string, so it doesn't reintroduce the argument corruption from sds#847.
1 parent 9532ca1 commit f288bed

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎lib/overcommit/utils/file_utils.rb‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ def readlink(link_name)
4949

5050
def win32_dir_cmd(file_name)
5151
Overcommit::Subprocess.spawn(
52-
%W[dir #{win32_fix_pathsep(file_name)}]
52+
%W[cmd.exe /c dir #{win32_fix_pathsep(file_name)}]
5353
)
5454
end
5555

5656
def win32_mklink_cmd(old_name, new_name)
5757
Overcommit::Subprocess.spawn(
58-
%W[mklink #{win32_fix_pathsep(new_name)} #{win32_fix_pathsep(old_name)}]
58+
%W[cmd.exe /c mklink #{win32_fix_pathsep(new_name)} #{win32_fix_pathsep(old_name)}]
5959
)
6060
end
6161

0 commit comments

Comments
 (0)