From bba859cd85b90dd9e4e6fd44b2af4aa64ae801a1 Mon Sep 17 00:00:00 2001 From: Jesung Yang Date: Thu, 15 Jan 2026 14:32:42 +0900 Subject: [PATCH] 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: - https://github.com/yazi-rs/yazi-rs.github.io/blob/2c839b37c80917ac3cf2d8c98949a392212d93ba/docs/quick-start.md?plain=1#L29 - https://github.com/yazi-rs/yazi-rs.github.io/blob/2c839b37c80917ac3cf2d8c98949a392212d93ba/docs/quick-start.md?plain=1#L56 --- modules/programs/yazi.nix | 4 ++-- tests/modules/programs/yazi/bash-integration-enabled.nix | 2 +- tests/modules/programs/yazi/nushell-integration-enabled.nix | 2 +- tests/modules/programs/yazi/zsh-integration-enabled.nix | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/programs/yazi.nix b/modules/programs/yazi.nix index 6d8dbe0f..0fcf0247 100644 --- a/modules/programs/yazi.nix +++ b/modules/programs/yazi.nix @@ -220,7 +220,7 @@ in bashIntegration = '' function ${cfg.shellWrapperName}() { local tmp="$(mktemp -t "yazi-cwd.XXXXX")" - yazi "$@" --cwd-file="$tmp" + command yazi "$@" --cwd-file="$tmp" if cwd="$(<"$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then builtin cd -- "$cwd" fi @@ -240,7 +240,7 @@ in nushellIntegration = '' def --env ${cfg.shellWrapperName} [...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 diff --git a/tests/modules/programs/yazi/bash-integration-enabled.nix b/tests/modules/programs/yazi/bash-integration-enabled.nix index 41f56d76..1f8538a9 100644 --- a/tests/modules/programs/yazi/bash-integration-enabled.nix +++ b/tests/modules/programs/yazi/bash-integration-enabled.nix @@ -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"' diff --git a/tests/modules/programs/yazi/nushell-integration-enabled.nix b/tests/modules/programs/yazi/nushell-integration-enabled.nix index cae01627..110e27e7 100644 --- a/tests/modules/programs/yazi/nushell-integration-enabled.nix +++ b/tests/modules/programs/yazi/nushell-integration-enabled.nix @@ -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 diff --git a/tests/modules/programs/yazi/zsh-integration-enabled.nix b/tests/modules/programs/yazi/zsh-integration-enabled.nix index 6087810c..6ae62912 100644 --- a/tests/modules/programs/yazi/zsh-integration-enabled.nix +++ b/tests/modules/programs/yazi/zsh-integration-enabled.nix @@ -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"'