From cb30f19c32f0f09320af7c498325d5bdc6803988 Mon Sep 17 00:00:00 2001 From: rootiest Date: Mon, 22 Jun 2026 02:16:40 -0400 Subject: [PATCH 1/2] feat(fish-deps): resolve real binary past our generated wrapper shims Add __fish_real_command, which walks all PATH matches for a name and returns the first that is NOT one of this config's generated wrappers (identified by the "# -wrapper-version:" marker; grep -I treats real ELF binaries as no-match so only our text shims are skipped). It never returns one of our own wrappers, so a caller embedding the result can't build a shim that recurses into itself. Use it for the fish-deps status "(Found at ...)" path so paru/yay show the real binary instead of the ~/.local/bin logging shim. --- functions/__fish_real_command.fish | 36 ++++++++++++++++++++++++++++++ functions/_fish_deps_status.fish | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 functions/__fish_real_command.fish diff --git a/functions/__fish_real_command.fish b/functions/__fish_real_command.fish new file mode 100644 index 0000000..743c7b7 --- /dev/null +++ b/functions/__fish_real_command.fish @@ -0,0 +1,36 @@ +# Copyright (C) 2026 Rootiest +# SPDX-License-Identifier: AGPL-3.0-or-later + +# SYNOPSIS +# __fish_real_command +# +# DESCRIPTION +# Resolves the real on-disk binary for , skipping any of this +# config's own generated wrapper shims. The PTY-logging wrappers we drop +# in ~/.local/bin (paru, yay) shadow the real binary on PATH; this walks +# every PATH match in order and returns the first one that is NOT one of +# our wrappers, identified by the "# -wrapper-version:" marker line. +# +# This intentionally never returns one of our own wrappers, so callers +# that embed the result in a generated wrapper cannot create a shim that +# recurses into itself. +# +# ARGUMENTS +# name Command name to resolve (e.g. paru, yay) +# +# RETURNS +# 0 Real binary path printed to stdout +# 1 No non-wrapper binary found on PATH (nothing printed) +# +# EXAMPLE +# set -l real (__fish_real_command paru) # -> /usr/bin/paru, not the shim +function __fish_real_command --argument-names name + for p in (command -sa $name) + # -I: binary files (real ELF binaries) count as no-match and are + # returned; only our text wrapper scripts carry the marker and skip. + grep -qsIF -- "# $name-wrapper-version:" $p; and continue + echo $p + return 0 + end + return 1 +end diff --git a/functions/_fish_deps_status.fish b/functions/_fish_deps_status.fish index 4ed2882..20532cd 100644 --- a/functions/_fish_deps_status.fish +++ b/functions/_fish_deps_status.fish @@ -30,7 +30,7 @@ function _fish_deps_status end set_color green; echo -n " ✓ "; set_color normal echo -n "$bin " - set_color brblack; echo "(Found at "(command -s $bin)")"; set_color normal + set_color brblack; echo "(Found at "(__fish_real_command $bin)")"; set_color normal else if test "$tier" = rec set_color yellow; echo -n " ⚠ "; set_color normal echo -n "$bin " From f92ac6ac37422e3b4ee445a67c10a1ee4fd3bdeb Mon Sep 17 00:00:00 2001 From: rootiest Date: Mon, 22 Jun 2026 02:16:41 -0400 Subject: [PATCH 2/2] fix(paru/yay-wrapper): resolve real binary instead of assuming /usr/bin The generated PTY-logging wrappers hardcoded /usr/bin/{paru,yay} both for the presence check and as the command the wrapper shells out to, breaking on any host where the binary lives elsewhere. Resolve the real path via __fish_real_command (which skips our own shim) and embed that. Bump the wrapper version 5 -> 6 so existing installs regenerate. --- conf.d/paru-wrapper.fish | 11 ++++++----- conf.d/yay-wrapper.fish | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/conf.d/paru-wrapper.fish b/conf.d/paru-wrapper.fish index a3d2a01..13e3159 100644 --- a/conf.d/paru-wrapper.fish +++ b/conf.d/paru-wrapper.fish @@ -2,7 +2,7 @@ # SPDX-License-Identifier: AGPL-3.0-or-later # # Generates ~/.local/bin/paru on first run (and on version bump) when -# /usr/bin/paru is installed. The wrapper runs paru in a PTY so progress +# paru is installed. The wrapper runs paru in a PTY so progress # bars are preserved, renders the captured animation to a clean static log # (via scripts/clean_progress_log.py), and prunes old logs. @@ -19,12 +19,13 @@ if not __fish_config_op_enabled __fish_config_op_logging return end -set -l _paru_real /usr/bin/paru +# Resolve the real paru binary, skipping our own shim (never /usr/bin-assumed). +set -l _paru_real (__fish_real_command paru) set -l _paru_wrapper "$HOME/.local/bin/paru" -set -l _paru_wrapper_version 5 +set -l _paru_wrapper_version 6 # Skip entirely if the real paru binary isn't present -test -x $_paru_real; or return +test -x "$_paru_real"; or return # Check if wrapper already exists at the expected version if test -f $_paru_wrapper @@ -48,7 +49,7 @@ printf '%s\n' \ '' \ '# Build a safely-quoted command string for script(1).' \ '# script(1) allocates a PTY so paru detects a real terminal and shows progress.' \ - 'cmd_str="/usr/bin/paru"' \ + "cmd_str=\"$_paru_real\"" \ 'for arg in "$@"; do' \ ' cmd_str+=" $(printf '"'"'%q'"'"' "$arg")"' \ 'done' \ diff --git a/conf.d/yay-wrapper.fish b/conf.d/yay-wrapper.fish index 1a42a6b..203f306 100644 --- a/conf.d/yay-wrapper.fish +++ b/conf.d/yay-wrapper.fish @@ -2,7 +2,7 @@ # SPDX-License-Identifier: AGPL-3.0-or-later # # Generates ~/.local/bin/yay on first run (and on version bump) when -# /usr/bin/yay is installed. The wrapper runs yay in a PTY so progress +# yay is installed. The wrapper runs yay in a PTY so progress # bars are preserved, renders the captured animation to a clean static log # (via scripts/clean_progress_log.py), and prunes old logs. @@ -19,12 +19,13 @@ if not __fish_config_op_enabled __fish_config_op_logging return end -set -l _yay_real /usr/bin/yay +# Resolve the real yay binary, skipping our own shim (never /usr/bin-assumed). +set -l _yay_real (__fish_real_command yay) set -l _yay_wrapper "$HOME/.local/bin/yay" -set -l _yay_wrapper_version 5 +set -l _yay_wrapper_version 6 # Skip entirely if the real yay binary isn't present -test -x $_yay_real; or return +test -x "$_yay_real"; or return # Check if wrapper already exists at the expected version if test -f $_yay_wrapper @@ -48,7 +49,7 @@ printf '%s\n' \ '' \ '# Build a safely-quoted command string for script(1).' \ '# script(1) allocates a PTY so yay detects a real terminal and shows progress.' \ - 'cmd_str="/usr/bin/yay"' \ + "cmd_str=\"$_yay_real\"" \ 'for arg in "$@"; do' \ ' cmd_str+=" $(printf '"'"'%q'"'"' "$arg")"' \ 'done' \