ajeetdsouza / zoxide

A smarter cd command. Supports all major shells.
MIT License
22.02k stars 536 forks source link

Nushell failure on `z` for keyword not under $env.PWD #834

Closed tingerrr closed 4 months ago

tingerrr commented 4 months ago

As of nushell#12975, path type will fail if a path is unknown, instead of returning an empty string.

This breaks the nushell init script for the first case of the __zoxide_z:

# Jump to a directory using only keywords.
def --env __zoxide_z [...rest:string] {
  let arg0 = ($rest | append '~').0
  let path = if (($rest | length) <= 1) and ($arg0 == '-' or ($arg0 | path expand | path type) == dir) {
    $arg0
  } else {
    (zoxide query --exclude $env.PWD -- ...$rest | str trim -r -c "\n")
  }
  cd $path
}

Specifically, if $arg0 is a keyword and is not a path in $env.PWD, then ($arg0 | path expand | path type) will return an error instead of evaluating to false.

tingerrr commented 4 months ago

I see this was fixed under #830 already.