From cb30f19c32f0f09320af7c498325d5bdc6803988 Mon Sep 17 00:00:00 2001 From: rootiest Date: Mon, 22 Jun 2026 02:16:40 -0400 Subject: [PATCH] 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 "