checked dependencies, made some optional, document optional dependencies

This commit is contained in:
fatalerrors
2026-06-02 17:49:16 +02:00
parent f0c62a5e7f
commit 462efef034
5 changed files with 78 additions and 13 deletions

View File

@@ -199,7 +199,7 @@ export -f ppn
# ------------------------------------------------------------------------------
# Get PID list of the given process name
# Usage: ppid <process_name [process_name2 ...]>
# Usage: gpid <process_name [process_name2 ...]>
gpid()
{
local PARSED
@@ -361,16 +361,33 @@ ku()
disp E "User '$u' does not exist."
return 1
else
local cmd=(killall)
local cmd
if [[ ${#signal_opt[@]} -gt 0 ]]; then
cmd+=("${signal_opt[@]}")
elif [[ -n "${KU_DEFAULT_SIGNAL:-}" ]]; then
cmd+=("-${KU_DEFAULT_SIGNAL}")
# killall (psmisc) preferred; fall back to pkill (procps-ng).
if command -v killall >/dev/null 2>&1; then
cmd=(killall)
if [[ ${#signal_opt[@]} -gt 0 ]]; then
cmd+=("${signal_opt[@]}")
elif [[ -n "${KU_DEFAULT_SIGNAL:-}" ]]; then
cmd+=("-${KU_DEFAULT_SIGNAL}")
fi
cmd+=(-u "$u")
elif command -v pkill >/dev/null 2>&1; then
cmd=(pkill)
# Translate killall's -s SIGNAME form to pkill's -SIGNAME form.
if [[ ${#signal_opt[@]} -eq 2 && "${signal_opt[0]}" == "-s" ]]; then
cmd+=("-${signal_opt[1]}")
elif [[ ${#signal_opt[@]} -gt 0 ]]; then
cmd+=("${signal_opt[@]}")
elif [[ -n "${KU_DEFAULT_SIGNAL:-}" ]]; then
cmd+=("-${KU_DEFAULT_SIGNAL}")
fi
cmd+=(-u "$u")
else
disp E "ku: neither 'killall' (psmisc) nor 'pkill' (procps) is available."
return 1
fi
cmd+=(-u "$u")
if (( dry_run )); then
printf "DRY-RUN: "
printf "%q " "${cmd[@]}"