Skip to content

Commit e7f102b

Browse files
authored
avoid temp filename collisions
1 parent a7c0e06 commit e7f102b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

vendor/lib/lib_path.cmd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,14 @@ exit /b
128128

129129
:toolong
130130
set "_rand=%RANDOM%"
131+
if exist "%temp%\%_rand%_cmder_lib_pathA" del "%temp%\%_rand%_cmder_lib_pathA" 2>nul 1>nul
132+
if exist "%temp%\%_rand%_cmder_lib_pathB" del "%temp%\%_rand%_cmder_lib_pathB" 2>nul 1>nul
133+
if exist "%temp%\%_rand%_cmder_lib_pathA" goto :toolong
134+
if exist "%temp%\%_rand%_cmder_lib_pathB" goto :toolong
131135
echo "%OLD_PATH%">"%temp%\%_rand%_cmder_lib_pathA"
136+
if errorlevel 1 ( if exist "%temp%\%_rand%_cmder_lib_pathA" del "%temp%\%_rand%_cmder_lib_pathA" & goto :toolong )
132137
echo "%PATH%">"%temp%\%_rand%_cmder_lib_pathB"
138+
if errorlevel 1 ( if exist "%temp%\%_rand%_cmder_lib_pathA" del "%temp%\%_rand%_cmder_lib_pathA" & if exist "%temp%\%_cmder_lib_pathB" del "%temp%\%_rand%_cmder_lib_pathB" & goto :toolong )
133139
fc /b "%temp%\%_rand%_cmder_lib_pathA" "%temp%\%_rand%_cmder_lib_pathB" 2>nul 1>nul
134140
if errorlevel 1 ( del "%temp%\%_rand%_cmder_lib_pathA" & del "%temp%\%_rand%_cmder_lib_pathB" & set "_rand=" & goto :changed )
135141
del "%temp%\%_rand%_cmder_lib_pathA" & del "%temp%\%_rand%_cmder_lib_pathB" & set "_rand="

0 commit comments

Comments
 (0)