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' \ 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 "