From ba5bdd94adcdb17752ce328bdd33c19f6f216391 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Sun, 7 Dec 2025 21:30:23 +0100 Subject: [PATCH] fix(tools.func): handle empty grep results in stop_all_services (#9748) --- misc/tools.func | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/misc/tools.func b/misc/tools.func index 5c031df2bf..67e929189d 100644 --- a/misc/tools.func +++ b/misc/tools.func @@ -72,17 +72,17 @@ stop_all_services() { local service_patterns=("$@") for pattern in "${service_patterns[@]}"; do - # Find all matching services + # Find all matching services (grep || true to handle no matches) + local services + services=$(systemctl list-units --type=service --all 2>/dev/null | + grep -oE "${pattern}[^ ]*\.service" 2>/dev/null | sort -u) || true - systemctl list-units --type=service --all 2>/dev/null | - grep -oE "${pattern}[^ ]*\.service" | - sort -u | + if [[ -n "$services" ]]; then while read -r service; do - $STD systemctl stop "$service" 2>/dev/null || true $STD systemctl disable "$service" 2>/dev/null || true - done - + done <<<"$services" + fi done }