code quality

This commit is contained in:
fatalerrors
2026-03-25 20:43:06 +01:00
parent 84e6fdd429
commit 60a159c3ea

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# ------------------------------------------------------------------------------
# Copyright (c) 2013-2026 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# Protected by the BSD3 license. Please read bellow for details.
#
# * Redistribution and use in source and binary forms,
@@ -128,12 +128,12 @@ gpid()
for pid in $@; do
local result=$(ps $psopt | grep $pid | awk '{print $1}' | sed "s/\n/ /")
if [[ $single ]]; then
[[ $result ]] && echo "${result//$'\n'/ }"
[[ -n "$result" ]] && echo "${result//$'\n'/ }"
else
[[ $result ]] && echo "$pid: ${result//$'\n'/ }"
[[ -n "$result" ]] && echo "$pid: ${result//$'\n'/ }"
fi
done
[[ $result ]] || return 1
[[ -n "$result" ]] || return 1
}
export -f gpid
# ------------------------------------------------------------------------------
@@ -155,8 +155,14 @@ ku()
disp E "Usage: ku <username1 [username2 ...]>"
return 1
fi
for u in $@; do
killall -u "$u"
local users="$@"
for u in $users; do
if ! id "$u" >/dev/null 2>&1; then
disp E "User '$u' does not exist."
return 1
else
killall -u "$u"
fi
done
}
export -f ku
@@ -187,7 +193,7 @@ kt()
return 1
fi
children_pids=$(pgrep -P "$parent_pid")
local children_pids=$(pgrep -P "$parent_pid")
for pid in $children_pids; do
kt "$pid" "$@" || break
@@ -198,3 +204,4 @@ kt()
# EOF