Fix cd-temp.ps1

This commit is contained in:
Markus Fleschutz 2022-02-25 13:11:33 +01:00
parent 3618087c25
commit 447560ef34

View File

@ -13,16 +13,18 @@
#>
function GetTempDir {
if ($IsLinux) { return "/tmp" }
return "$env:TEMP"
if ("$env:TEMP" -ne "") { return "$env:TEMP" }
if ("$env:TMP" -ne "") { return "$env:TMP" }
if ($IsLinux) { return "/tmp" }
return "C:\Temp"
}
try {
$Path = resolve-path GetTempDir
if (-not(test-path "$Path" -pathType container)) {
$Path = GetTempDir
if (-not(Test-Path "$Path" -pathType container)) {
throw "Temporary folder at 📂$Path doesn't exist (yet)"
}
set-location "$Path"
Set-Location "$Path"
"📂$Path"
exit 0 # success
} catch {