These eight ignore $argv entirely, so passing --help ran the command
instead of describing it. The new check shadows every external binary
they reach with a recording stub on PATH and fails if anything is
invoked. Before the fix it reported, verbatim:
cleanup --help EXECUTED: pacman -Qtdq
fzf-update --help EXECUTED: git clone --depth 1 https://github.com/junegunn/fzf.git /tmp/.../.fzf
limine-edit --help EXECUTED: sudoedit /boot/limine.conf sudo limine-enroll-config sudo limine-mkinitcpio sudo sbctl sign-all
lock --help EXECUTED: loginctl lock-session
screensleep --help EXECUTED: busctl --user call org.kde.kglobalaccel ... invokeShortcut s Turn Off Screen
sudo-toggle --help EXECUTED: sudo stat -c %s /etc/sudoers.d/nofail-toggle sudo tee /etc/sudoers.d/nofail-toggle
tmux-clean --help EXECUTED: tmux list-sessions -F #{session_name} #{session_attached}
upgrade --help EXECUTED: paru -Syu --noconfirm
cleanup's log line is the read that precedes `sudo pacman -Rns $orphans`,
which the stub suppressed by returning no orphans; on a real machine with
orphans present the removal ran.
Each now answers --help from its own comment header. The call site is the
first statement of the body, above the C4 guard, so help stays reachable
when the component is disabled and nothing side-effecting runs first.
31 lines
883 B
Fish
31 lines
883 B
Fish
# Copyright (C) 2026 Rootiest
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
# CATEGORY
|
|
# 05-package-management
|
|
#
|
|
# SYNOPSIS
|
|
# cleanup
|
|
#
|
|
# DESCRIPTION
|
|
# Identifies and removes Arch Linux orphan packages using pacman. Logs
|
|
# package names and versions to ~/.removed_orphans before removal.
|
|
#
|
|
# EXAMPLE
|
|
# cleanup
|
|
function cleanup --description 'Log orphans to ~/.removed_orphans and remove them'
|
|
__fish_help_header (status current-function) $argv; and return 0
|
|
|
|
set -l orphans (pacman -Qtdq)
|
|
if test -n "$orphans"
|
|
echo "📝 Logging orphans to ~/.removed_orphans..."
|
|
echo "--- Removed on $(date) ---" >> ~/.removed_orphans
|
|
pacman -Qi $orphans | grep -E '^(Name|Version)' >> ~/.removed_orphans
|
|
|
|
echo "🧹 Removing orphans..."
|
|
sudo pacman -Rns $orphans
|
|
else
|
|
echo "✨ No orphans to clean up!"
|
|
end
|
|
end
|