Skip to content

Commit 9c0eb6c

Browse files
authored
Merge pull request #127 from chrisant996/fixpushd
Fix leaked pushd
2 parents 831d617 + e646d5b commit 9c0eb6c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

z.cmd

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,23 @@ if /i "%RunMode%"=="-n" (
106106
pushd !NewPath!
107107
pushd !NewPath!
108108
endlocal
109-
popd
109+
goto popdir
110110
)
111111
)
112112
) else (
113113
call "%LuaExe%" "%LuaScript%" "%RunMode%" %MatchType% %StrictSub% %InterMode% %StripMode% %*
114114
)
115115

116+
goto end
117+
118+
:popdir
119+
rem -- Exploits variable expansion and the pushd stack to set the current
120+
rem -- directory without leaking a pushd.
121+
popd
122+
setlocal
123+
set NewPath=%CD%
124+
endlocal & popd & cd /d "%NewPath%"
125+
116126
:end
117127
echo.
118128

0 commit comments

Comments
 (0)