Merge pull request 'fix(fish-deps): show real binary path + drop hardcoded /usr/bin in paru/yay wrappers' (#62) from fish-deps-real-binary-resolution into main
Reviewed-on: #62
This commit was merged in pull request #62.
This commit is contained in:
@@ -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' \
|
||||
|
||||
@@ -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' \
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
# Copyright (C) 2026 Rootiest
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
# SYNOPSIS
|
||||
# __fish_real_command <name>
|
||||
#
|
||||
# DESCRIPTION
|
||||
# Resolves the real on-disk binary for <name>, 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 "# <name>-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
|
||||
@@ -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 "
|
||||
|
||||
Reference in New Issue
Block a user