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

@@ -471,6 +471,12 @@ file_stats()
fi
# Minimum/maximum size filters (evaluated in bytes)
if [[ -n "$min_size" || -n "$max_size" ]]; then
if ! command -v numfmt >/dev/null 2>&1; then
disp E "file_stats: --min/--max require 'numfmt' (GNU coreutils). Please install it."
return 1
fi
fi
if [[ -n "$min_size" ]]; then
find_cmd+=(-size +"$(numfmt --from=iec "$min_size")"c)
fi

View File

@@ -94,6 +94,11 @@ busy()
delay_s=$(awk "BEGIN{
printf \"%.3f\", $delay_ms / 1000 }")
command -v hexdump >/dev/null 2>&1 || {
disp E "busy: 'hexdump' is required but not installed (util-linux or bsdmainutils)."
return 1
}
# Monitor /dev/urandom
(
hexdump -C < /dev/urandom | grep -iF --line-buffered "$pattern" | \

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[@]}"