fix(help): stop eight functions executing on --help
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.
This commit is contained in:
@@ -14,6 +14,8 @@
|
||||
# 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..."
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
# EXAMPLE
|
||||
# fzf-update
|
||||
function fzf-update --description 'Install or upgrade fzf from git HEAD'
|
||||
__fish_help_header (status current-function) $argv; and return 0
|
||||
|
||||
if test -d ~/.fzf
|
||||
echo "Updating fzf..."
|
||||
git -C ~/.fzf pull --ff-only
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
# EXAMPLE
|
||||
# limine-edit
|
||||
function limine-edit --description 'Safely edit and re-verify Limine configuration'
|
||||
__fish_help_header (status current-function) $argv; and return 0
|
||||
|
||||
# 1. Open the config with sudoedit
|
||||
sudoedit /boot/limine.conf
|
||||
|
||||
|
||||
@@ -13,5 +13,7 @@
|
||||
# EXAMPLE
|
||||
# lock
|
||||
function lock --wraps='loginctl' --description 'alias lock=loginctl'
|
||||
__fish_help_header (status current-function) $argv; and return 0
|
||||
|
||||
loginctl lock-session
|
||||
end
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
# EXAMPLE
|
||||
# screensleep
|
||||
function screensleep --description 'Turn off the display using KDE PowerDevil'
|
||||
__fish_help_header (status current-function) $argv; and return 0
|
||||
|
||||
# Optional: 1-second delay to ensure no keystrokes wake it immediately
|
||||
sleep 1
|
||||
busctl --user call \
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
# EXAMPLE
|
||||
# sudo-toggle
|
||||
function sudo-toggle --description 'Toggle sudo password requirement on/off'
|
||||
__fish_help_header (status current-function) $argv; and return 0
|
||||
|
||||
# Check the file size using sudo stat to see if our bypass rule is active
|
||||
set -l file_size (sudo stat -c %s /etc/sudoers.d/nofail-toggle 2>/dev/null)
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
# EXAMPLE
|
||||
# tmux-clean
|
||||
function tmux-clean --description 'Kill all tmux sessions except the current one'
|
||||
__fish_help_header (status current-function) $argv; and return 0
|
||||
|
||||
# Get a list of all session names that are NOT currently attached
|
||||
set sessions (tmux list-sessions -F '#{session_name} #{session_attached}' | string match -rv ' 1$' | string split -f1 ' ')
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
# EXAMPLE
|
||||
# upgrade
|
||||
function upgrade --description 'Full system upgrade via paru or yay'
|
||||
__fish_help_header (status current-function) $argv; and return 0
|
||||
|
||||
# Opinionated guard (C4): integrations disabled
|
||||
if not __fish_config_op_enabled (status current-function)
|
||||
set -l c_err (set_color red)
|
||||
|
||||
Reference in New Issue
Block a user