Profile update/fixes
Fixed Get-PowerShellPath - was failing when a zombie process was alive Fixed Remove-Item failing when setting up profile.
This commit is contained in:
parent
b9c429ece4
commit
9dca986b74
|
@ -174,7 +174,7 @@ Get-Command Reload-MyScripts -ErrorAction SilentlyContinue | ForEach-Object { .
|
|||
$local:errMsg = $(Invoke-ExpressionEx -sudo:$shouldSudo @"
|
||||
if( -not (Test-Path $(Split-Path -Parent $p)) ) { New-Item -Type Directory $(Split-Path -Parent $p) -Force };
|
||||
Copy-Item $($tmpOutput.FullName) $p -Force:`$$Force -ErrorAction Stop | Out-Null;
|
||||
Remove-Item $($tmpOutput.FullName) -Force:`$$Force -ErrorAction Stop
|
||||
Remove-Item $($tmpOutput.FullName) -Force:`$$Force -ErrorAction SilentlyContinue
|
||||
"@ 2>&1)
|
||||
if ( $errMsg ) {
|
||||
Write-Error "$errMsg"
|
||||
|
@ -223,7 +223,7 @@ Get-Command Reload-MyScripts -ErrorAction SilentlyContinue | ForEach-Object { .
|
|||
#######################################################################
|
||||
function ProfileCode_common {
|
||||
function Get-PowerShellPath {
|
||||
Get-Process -PID $PID | ForEach-Object { $_.Path, $_.Parent.Path } | Where-Object { $_ -match 'powershell|pwsh' } | Select-Object -First 1
|
||||
Get-Process -PID $PID | ForEach-Object { $_.Path, $_.Parent.Path } | Where-Object { $_ -match $('(powershell|pwsh)' + "`$") } | Select-Object -First 1
|
||||
}
|
||||
|
||||
function ConvertTo-Base64 {
|
||||
|
@ -254,10 +254,10 @@ function Invoke-ExpressionEx {
|
|||
$local:sudo_exec = [string]::Empty
|
||||
if ( (Get-Command scoop -ErrorAction SilentlyContinue) ) {
|
||||
$sudo_exec = $(scoop which gsudo *>&1)
|
||||
if ( $sudo_exec -match 'not found' ) {
|
||||
if ( "$sudo_exec" -match 'not found' ) {
|
||||
$sudo_exec = $(scoop which sudo *>&1)
|
||||
}
|
||||
if ( $sudo_exec -match 'not found' ) { $sudo_exec = [string]::Empty }
|
||||
if ( "$sudo_exec" -match 'not found' ) { $sudo_exec = [string]::Empty }
|
||||
}
|
||||
if ( $sudo_exec ) {
|
||||
& $sudo_exec $sudo_cmd
|
||||
|
|
Loading…
Reference in New Issue