yazi: fix unintended recursive calls

Use `command` (POSIX) and `^` (Nushell) to prevent recursive function
calls when `cfg.shellWrapperName` is set to "yazi".

Previously, if `cfg.shellWrapperName` was set to "yazi", the invocation
of `yazi` within the shell integration function triggered the function
itself instead of the binary. This name conflict prevents users from
using the binary name as-is when shell integration is enabled.

Hence, fix this by using shell-specific mechanisms to target the
underlying executable, bypassing any name collisions.

This aligns with the official documentation:
- 2c839b37c8/docs/quick-start.md (L29)
- 2c839b37c8/docs/quick-start.md (L56)
This commit is contained in:
Jesung Yang 2026-01-15 14:32:42 +09:00 committed by Austin Horstman
parent cae8abb629
commit bba859cd85
4 changed files with 5 additions and 5 deletions

View file

@ -10,7 +10,7 @@
assertFileExists home-files/.bashrc
assertFileContains home-files/.bashrc 'function yy() {'
assertFileContains home-files/.bashrc 'local tmp="$(mktemp -t "yazi-cwd.XXXXX")"'
assertFileContains home-files/.bashrc 'yazi "$@" --cwd-file="$tmp"'
assertFileContains home-files/.bashrc 'command yazi "$@" --cwd-file="$tmp"'
assertFileContains home-files/.bashrc 'if cwd="$(<"$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then'
assertFileContains home-files/.bashrc 'builtin cd -- "$cwd"'
assertFileContains home-files/.bashrc 'rm -f -- "$tmp"'

View file

@ -4,7 +4,7 @@ let
shellIntegration = ''
def --env yy [...args] {
let tmp = (mktemp -t "yazi-cwd.XXXXX")
yazi ...$args --cwd-file $tmp
^yazi ...$args --cwd-file $tmp
let cwd = (open $tmp)
if $cwd != "" and $cwd != $env.PWD {
cd $cwd

View file

@ -10,7 +10,7 @@
assertFileExists home-files/.zshrc
assertFileContains home-files/.zshrc 'function yy() {'
assertFileContains home-files/.zshrc 'local tmp="$(mktemp -t "yazi-cwd.XXXXX")"'
assertFileContains home-files/.zshrc 'yazi "$@" --cwd-file="$tmp"'
assertFileContains home-files/.zshrc 'command yazi "$@" --cwd-file="$tmp"'
assertFileContains home-files/.zshrc 'if cwd="$(<"$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then'
assertFileContains home-files/.zshrc 'builtin cd -- "$cwd"'
assertFileContains home-files/.zshrc 'rm -f -- "$tmp"'