diff --git a/profile.d/processes.sh b/profile.d/processes.sh index b474f9b..ee1ebf5 100644 --- a/profile.d/processes.sh +++ b/profile.d/processes.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # ------------------------------------------------------------------------------ -# Copyright (c) 2013-2026 Geoffray Levasseur +# Copyright (c) 2013-2022 Geoffray Levasseur # 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 " 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 +