Skip to content

Zoxide powershell init script has a uncatched exception which may influence user's $Error handle. #1061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Zim-Inn opened this issue May 23, 2025 · 0 comments

Comments

@Zim-Inn
Copy link

Zim-Inn commented May 23, 2025

As below, Get-Variable __zoxide_hooked always occurr a exception when my script exec $psGroup = Get-Process -Name $ProcessNameList -ErrorAction SilentlyContinue | group -Property Path

# Initialize hook.
$global:__zoxide_hooked = (Get-Variable __zoxide_hooked -ErrorAction SilentlyContinue -ValueOnly)
if ($global:__zoxide_hooked -ne 1) {
    $global:__zoxide_hooked = 1
    $global:__zoxide_prompt_old = $function:prompt

    function global:prompt {
        if ($null -ne $__zoxide_prompt_old) {
            & $__zoxide_prompt_old
        }
        $null = __zoxide_hook
    }
}

I think add a try catch for it will be better

try {
    $global:__zoxide_hooked = (Get-Variable __zoxide_hooked -ValueOnly -ErrorAction Stop)
} catch {
    $global:__zoxide_hooked = 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant