fix: guard and document the external tools PR #168 flagged as unguarded
PR #168's Notes section named several functions with a real external-tool dependency that no `type -q`/`command -q`/`command -v`/ `which` guard covers anywhere in the tree, deliberately left out of DEPENDENCIES to avoid breaking test_dependencies_resolve. Adds the guard each was missing, then declares the dependency now that it resolves: - bkg, detach: nohup - gitui: gitui (self-shadow; type -q -f to skip the function itself) - play-media: mpv, vlc -- already guarded via `type -q -f $p` in a loop, just never recognized as one (see next point) - steam-dl: systemd-inhibit, steam - wake-lock: systemd-inhibit - split, spwin, tab: wezterm, konsole (kitty already declared) docs/verify-manual.py's guard-detection regex only matched `type -q <name>` immediately, so `type -q -f $p` (the `-f` flag excludes functions from the match, needed wherever a wrapper shadows a binary of its own name) was invisible to it -- both as a direct guard and through the loop-variable indirection. Broadened both patterns to skip over any flags between `-q` and the name/variable. split/spwin/tab dispatch on $TERM/$TERM_PROGRAM/$KONSOLE_VERSION to pick which terminal-specific binary to call, per this repo's C4 convention -- but those env vars only prove the terminal type, not that its CLI binary is on $PATH: they propagate over ssh, so sshing out from Kitty/WezTerm inherits the var on a remote host that never installed the binary. Same latent gap in clone/clonet, whose clone-in-kitty is a function Kitty's own shell integration injects, not present on a remote shell that only inherited $TERM. All five now check the actual thing they are about to call, not just the env var that selects it. Also guards and documents three more real, previously-undeclared dependencies found by the same audit, unrelated to PR #168's named list but the identical pattern: fast-cli (fast), lock (loginctl), ports (lsof), screensleep (busctl). docs/fish-config.md regenerated to match.
This commit is contained in:
@@ -4,6 +4,9 @@
|
||||
# CATEGORY
|
||||
# 08-terminal-management
|
||||
#
|
||||
# DEPENDENCIES
|
||||
# nohup
|
||||
#
|
||||
# SYNOPSIS
|
||||
# bkg <command> [args...]
|
||||
#
|
||||
@@ -32,6 +35,11 @@ function bkg --description 'Execute bkg'
|
||||
return 1
|
||||
end
|
||||
|
||||
if not type -q nohup
|
||||
echo (set_color red)"Error: nohup is not installed."(set_color normal) >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
# Run the command using nohup to make it immune to hangups (like closing the terminal).
|
||||
# Redirect both stdout and stderr to /dev/null to discard all output.
|
||||
# The final ampersand (&) sends the entire process to the background.
|
||||
|
||||
+11
-1
@@ -4,6 +4,9 @@
|
||||
# CATEGORY
|
||||
# 02-navigation
|
||||
#
|
||||
# DEPENDENCIES
|
||||
# clone-in-kitty
|
||||
#
|
||||
# SYNOPSIS
|
||||
# clone [args...]
|
||||
#
|
||||
@@ -16,7 +19,7 @@
|
||||
#
|
||||
# EXIT STATUS
|
||||
# 0 Repository cloned
|
||||
# 1 Not running inside Kitty terminal
|
||||
# 1 Not running inside Kitty terminal, or clone-in-kitty isn't available
|
||||
#
|
||||
# EXAMPLE
|
||||
# clone https://github.com/user/repo.git
|
||||
@@ -25,5 +28,12 @@ function clone --wraps='clone-in-kitty' --description 'alias clone=clone-in-kitt
|
||||
echo "Error: The 'clone' command requires Kitty terminal." >&2
|
||||
return 1
|
||||
end
|
||||
# $TERM only proves the terminal type -- clone-in-kitty is a function
|
||||
# Kitty's own shell integration injects, which doesn't happen over an
|
||||
# ssh session that merely inherits $TERM from the local Kitty.
|
||||
if not type -q clone-in-kitty
|
||||
echo "Error: 'clone' detected Kitty but clone-in-kitty isn't available (shell integration not loaded)." >&2
|
||||
return 1
|
||||
end
|
||||
clone-in-kitty $argv
|
||||
end
|
||||
|
||||
+11
-1
@@ -4,6 +4,9 @@
|
||||
# CATEGORY
|
||||
# 02-navigation
|
||||
#
|
||||
# DEPENDENCIES
|
||||
# clone-in-kitty
|
||||
#
|
||||
# SYNOPSIS
|
||||
# clonet [args...]
|
||||
#
|
||||
@@ -16,7 +19,7 @@
|
||||
#
|
||||
# EXIT STATUS
|
||||
# 0 Repository cloned
|
||||
# 1 Not running inside Kitty terminal
|
||||
# 1 Not running inside Kitty terminal, or clone-in-kitty isn't available
|
||||
#
|
||||
# EXAMPLE
|
||||
# clonet https://github.com/user/repo.git
|
||||
@@ -25,5 +28,12 @@ function clonet --wraps='clone-in-kitty --type=tab' --description 'alias clonet=
|
||||
echo "Error: The 'clonet' command requires Kitty terminal." >&2
|
||||
return 1
|
||||
end
|
||||
# $TERM only proves the terminal type -- clone-in-kitty is a function
|
||||
# Kitty's own shell integration injects, which doesn't happen over an
|
||||
# ssh session that merely inherits $TERM from the local Kitty.
|
||||
if not type -q clone-in-kitty
|
||||
echo "Error: 'clonet' detected Kitty but clone-in-kitty isn't available (shell integration not loaded)." >&2
|
||||
return 1
|
||||
end
|
||||
clone-in-kitty --type=tab $argv
|
||||
end
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
# CATEGORY
|
||||
# 08-terminal-management
|
||||
#
|
||||
# DEPENDENCIES
|
||||
# nohup
|
||||
#
|
||||
# SYNOPSIS
|
||||
# detach [-h] [--version] <command> [args...]
|
||||
#
|
||||
@@ -66,5 +69,10 @@ function detach --description 'Execute detach'
|
||||
return 1
|
||||
end
|
||||
|
||||
if not type -q nohup
|
||||
echo (set_color red)"Error: nohup is not installed."(set_color normal) >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
nohup $args >/dev/null 2>&1 &
|
||||
end
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
# CATEGORY
|
||||
# 10-network
|
||||
#
|
||||
# DEPENDENCIES
|
||||
# fast
|
||||
#
|
||||
# SYNOPSIS
|
||||
# fast-cli [args...]
|
||||
#
|
||||
@@ -13,8 +16,16 @@
|
||||
# ARGUMENTS
|
||||
# args... Arguments forwarded to the fast command
|
||||
#
|
||||
# EXIT STATUS
|
||||
# 1 fast is not installed
|
||||
# * Exit status of fast otherwise
|
||||
#
|
||||
# EXAMPLE
|
||||
# fast-cli
|
||||
function fast-cli --description "Run a speed test using fast.com"
|
||||
if not type -q -f fast
|
||||
echo (set_color red)"Error: fast is not installed."(set_color normal) >&2
|
||||
return 1
|
||||
end
|
||||
command fast $argv
|
||||
end
|
||||
|
||||
+12
-1
@@ -4,6 +4,9 @@
|
||||
# CATEGORY
|
||||
# 04-git-and-version-control
|
||||
#
|
||||
# DEPENDENCIES
|
||||
# gitui
|
||||
#
|
||||
# SYNOPSIS
|
||||
# gitui [args...]
|
||||
#
|
||||
@@ -14,9 +17,17 @@
|
||||
# ARGUMENTS
|
||||
# args... Arguments forwarded to the gitui command
|
||||
#
|
||||
# EXIT STATUS
|
||||
# 1 gitui is not installed
|
||||
# * Exit status of gitui otherwise
|
||||
#
|
||||
# EXAMPLE
|
||||
# gitui
|
||||
function gitui --wraps='gitui' --description 'alias gitui=gitui -t mocha.ron'
|
||||
command gitui -t frappe.ron $argv
|
||||
if not type -q -f gitui
|
||||
echo (set_color red)"Error: gitui is not installed."(set_color normal) >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
command gitui -t frappe.ron $argv
|
||||
end
|
||||
|
||||
+10
-1
@@ -4,6 +4,9 @@
|
||||
# CATEGORY
|
||||
# 07-system-and-monitoring
|
||||
#
|
||||
# DEPENDENCIES
|
||||
# loginctl
|
||||
#
|
||||
# SYNOPSIS
|
||||
# lock
|
||||
#
|
||||
@@ -11,12 +14,18 @@
|
||||
# Locks the current desktop session using loginctl lock-session.
|
||||
#
|
||||
# EXIT STATUS
|
||||
# Exit status of loginctl lock-session
|
||||
# 1 loginctl is not installed
|
||||
# * Exit status of loginctl lock-session otherwise
|
||||
#
|
||||
# EXAMPLE
|
||||
# lock
|
||||
function lock --wraps='loginctl' --description 'alias lock=loginctl'
|
||||
__fish_help_header (status current-function) $argv; and return 0
|
||||
|
||||
if not type -q loginctl
|
||||
echo (set_color red)"Error: loginctl is not installed."(set_color normal) >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
loginctl lock-session
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# 13-media-and-utilities
|
||||
#
|
||||
# DEPENDENCIES
|
||||
# _fzf_preview_media, _fzf_wrapper, fd, fdfind, file, xdg-mime
|
||||
# _fzf_preview_media, _fzf_wrapper, fd, fdfind, file, xdg-mime, mpv, vlc
|
||||
#
|
||||
# SYNOPSIS
|
||||
# play-media [-p|--player <cmd>]
|
||||
|
||||
+10
-1
@@ -4,6 +4,9 @@
|
||||
# CATEGORY
|
||||
# 07-system-and-monitoring
|
||||
#
|
||||
# DEPENDENCIES
|
||||
# lsof
|
||||
#
|
||||
# SYNOPSIS
|
||||
# ports
|
||||
#
|
||||
@@ -12,12 +15,18 @@
|
||||
# port numbers and addresses without hostname resolution.
|
||||
#
|
||||
# EXIT STATUS
|
||||
# Exit status of lsof
|
||||
# 1 lsof is not installed
|
||||
# * Exit status of lsof otherwise
|
||||
#
|
||||
# EXAMPLE
|
||||
# ports
|
||||
function ports --wraps='sudo' --description 'Show active network listeners'
|
||||
__fish_help_header (status current-function) $argv; and return 0
|
||||
|
||||
if not type -q lsof
|
||||
echo (set_color red)"Error: lsof is not installed."(set_color normal) >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
sudo lsof -iTCP -sTCP:LISTEN -P -n
|
||||
end
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
# CATEGORY
|
||||
# 07-system-and-monitoring
|
||||
#
|
||||
# DEPENDENCIES
|
||||
# busctl
|
||||
#
|
||||
# SYNOPSIS
|
||||
# screensleep
|
||||
#
|
||||
@@ -12,13 +15,19 @@
|
||||
# PowerDevil "Turn Off Screen" global shortcut via busctl.
|
||||
#
|
||||
# EXIT STATUS
|
||||
# Exit status of busctl
|
||||
# 1 busctl is not installed
|
||||
# * Exit status of busctl otherwise
|
||||
#
|
||||
# EXAMPLE
|
||||
# screensleep
|
||||
function screensleep --description 'Turn off the display using KDE PowerDevil'
|
||||
__fish_help_header (status current-function) $argv; and return 0
|
||||
|
||||
if not type -q busctl
|
||||
echo (set_color red)"Error: busctl is not installed."(set_color normal) >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
# Optional: 1-second delay to ensure no keystrokes wake it immediately
|
||||
sleep 1
|
||||
busctl --user call \
|
||||
|
||||
+12
-1
@@ -8,7 +8,7 @@
|
||||
# integrations/window-mgmt
|
||||
#
|
||||
# DEPENDENCIES
|
||||
# kitty
|
||||
# kitty, wezterm
|
||||
#
|
||||
# SYNOPSIS
|
||||
# split [-h | -v] [command...]
|
||||
@@ -55,6 +55,17 @@ function split --description 'Run a command in a new terminal split'
|
||||
return 1
|
||||
end
|
||||
|
||||
# $TERM/$TERM_PROGRAM only prove the terminal type, not that its CLI
|
||||
# binary is on $PATH -- e.g. sshing out from Kitty/WezTerm inherits the
|
||||
# env var on the remote host without the binary. Check explicitly.
|
||||
if test $is_kitty -eq 1; and not type -q kitty
|
||||
echo "Error: 'split' detected Kitty but the kitty binary is not installed." >&2
|
||||
return 1
|
||||
else if test $is_wezterm -eq 1; and not type -q wezterm
|
||||
echo "Error: 'split' detected WezTerm but the wezterm binary is not installed." >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
set -l kitty_loc hsplit
|
||||
set -l wez_loc --bottom
|
||||
|
||||
|
||||
+12
-2
@@ -8,7 +8,7 @@
|
||||
# integrations/window-mgmt
|
||||
#
|
||||
# DEPENDENCIES
|
||||
# kitty
|
||||
# kitty, wezterm
|
||||
#
|
||||
# SYNOPSIS
|
||||
# spwin [args...]
|
||||
@@ -36,13 +36,23 @@ function spwin --wraps='~/.config/kitty/spawn-window.sh' --description 'spawn wi
|
||||
return 1
|
||||
end
|
||||
|
||||
# $TERM/$TERM_PROGRAM only prove the terminal type, not that its CLI
|
||||
# binary is on $PATH -- e.g. sshing out from Kitty/WezTerm inherits the
|
||||
# env var on the remote host without the binary. Check explicitly.
|
||||
if test "$TERM" = xterm-kitty
|
||||
if test -x ~/.config/kitty/spawn-window.sh
|
||||
~/.config/kitty/spawn-window.sh $argv
|
||||
else
|
||||
else if type -q kitty
|
||||
kitty @ launch --type=window $argv
|
||||
else
|
||||
echo "Error: 'spwin' detected Kitty but neither spawn-window.sh nor the kitty binary is available." >&2
|
||||
return 1
|
||||
end
|
||||
else if test "$TERM_PROGRAM" = WezTerm
|
||||
if not type -q wezterm
|
||||
echo "Error: 'spwin' detected WezTerm but the wezterm binary is not installed." >&2
|
||||
return 1
|
||||
end
|
||||
wezterm cli spawn $argv
|
||||
else
|
||||
echo "Error: The 'spwin' command requires Kitty or WezTerm." >&2
|
||||
|
||||
+12
-1
@@ -4,6 +4,9 @@
|
||||
# CATEGORY
|
||||
# 13-media-and-utilities
|
||||
#
|
||||
# DEPENDENCIES
|
||||
# systemd-inhibit, steam
|
||||
#
|
||||
# SYNOPSIS
|
||||
# steam-dl
|
||||
#
|
||||
@@ -12,13 +15,21 @@
|
||||
# or sleeping during active downloads.
|
||||
#
|
||||
# EXIT STATUS
|
||||
# Exit status of steam (via systemd-inhibit)
|
||||
# 1 systemd-inhibit or steam is not installed
|
||||
# * Exit status of steam (via systemd-inhibit) otherwise
|
||||
#
|
||||
# EXAMPLE
|
||||
# steam-dl
|
||||
function steam-dl --description 'Run Steam while inhibiting system sleep'
|
||||
__fish_help_header (status current-function) $argv; and return 0
|
||||
|
||||
for cmd in systemd-inhibit steam
|
||||
if not type -q $cmd
|
||||
echo (set_color red)"Error: $cmd is not installed."(set_color normal) >&2
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
||||
echo "Inhibiting sleep while Steam downloads..."
|
||||
systemd-inhibit --why="Active Download" --who="User" --what=idle:sleep steam
|
||||
end
|
||||
|
||||
+17
-1
@@ -8,7 +8,7 @@
|
||||
# integrations/window-mgmt
|
||||
#
|
||||
# DEPENDENCIES
|
||||
# kitty
|
||||
# kitty, wezterm, konsole
|
||||
#
|
||||
# SYNOPSIS
|
||||
# tab [args...]
|
||||
@@ -42,11 +42,27 @@ function tab --description 'Spawn a new tab in the current terminal'
|
||||
set dir "$PWD"
|
||||
end
|
||||
|
||||
# $TERM/$TERM_PROGRAM/$KONSOLE_VERSION only prove the terminal type,
|
||||
# not that its CLI binary is on $PATH -- e.g. sshing out from one of
|
||||
# these inherits the env var on the remote host without the binary.
|
||||
# Check explicitly.
|
||||
if test "$TERM" = xterm-kitty
|
||||
if not type -q kitty
|
||||
echo "Error: 'tab' detected Kitty but the kitty binary is not installed." >&2
|
||||
return 1
|
||||
end
|
||||
kitty @ launch --type=tab --cwd="$dir" $argv
|
||||
else if test "$TERM_PROGRAM" = WezTerm
|
||||
if not type -q wezterm
|
||||
echo "Error: 'tab' detected WezTerm but the wezterm binary is not installed." >&2
|
||||
return 1
|
||||
end
|
||||
wezterm cli spawn --cwd "$dir" $argv
|
||||
else if set -q KONSOLE_VERSION
|
||||
if not type -q konsole
|
||||
echo "Error: 'tab' detected Konsole but the konsole binary is not installed." >&2
|
||||
return 1
|
||||
end
|
||||
konsole --new-tab --workdir "$dir" $argv
|
||||
else
|
||||
echo "Error: No supported terminal found. Try Kitty, WezTerm, or Konsole." >&2
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
# CATEGORY
|
||||
# 14-miscellaneous
|
||||
#
|
||||
# DEPENDENCIES
|
||||
# systemd-inhibit
|
||||
#
|
||||
# SYNOPSIS
|
||||
# wake-lock <command> [args...]
|
||||
#
|
||||
@@ -17,7 +20,7 @@
|
||||
#
|
||||
# EXIT STATUS
|
||||
# 0 Command ran and completed
|
||||
# 1 No command provided
|
||||
# 1 No command provided, or systemd-inhibit is not installed
|
||||
#
|
||||
# EXAMPLE
|
||||
# wake-lock rsync -avz src/ dest/
|
||||
@@ -30,6 +33,11 @@ function wake-lock --description 'Run a command while inhibiting system sleep'
|
||||
return 1
|
||||
end
|
||||
|
||||
if not type -q systemd-inhibit
|
||||
echo (set_color red)"Error: systemd-inhibit is not installed."(set_color normal) >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
echo "Running '$argv' with sleep inhibition active..."
|
||||
|
||||
# --what=idle:sleep prevents the system from auto-sleeping or being suspended
|
||||
|
||||
Reference in New Issue
Block a user