Commit 9de230a3 authored by Dustin Howett's avatar Dustin Howett

[take] Use nested prompts instead of a subshell

parent 980bb510
......@@ -342,9 +342,18 @@ New-Alias -name vs -Value Import-VisualStudioVars
Function Take-TemporaryDirectory {
$TAKE = [System.IO.Path]::Combine($Env:TEMP, "take$(Get-Random)")
New-Item -ItemType Directory "$TAKE" -EA Stop | Out-Null
powershell.exe -NoProfile -NoLogo -Command "Set-Location `"$TAKE`"; powershell.exe -NoLogo"
Remove-Item -Recurse $TAKE
New-Item -ItemType:Directory -Path:"$TAKE" -ErrorAction:Stop > $Null
Push-Location -Path:$TAKE -StackName:"TakeStack" > $Null
#powershell.exe -NoProfile -NoLogo -Command "Set-Location `"$TAKE`"; powershell.exe -NoLogo"
Pop-Location -StackName:"TakeStack" > $Null
If($null -Eq (Get-Item (Join-Path -Path:$TAKE -ChildPath:".keep") -ErrorAction:Ignore)) {
Remove-Item -Recurse $TAKE
Write-Warning "Removed temporary directory $TAKE"
} Else {
Get-Item $TAKE
New-Alias -Name take -Value Take-TemporaryDirectory
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment