fix(tools.func): handle empty grep results in stop_all_services (#9748)

This commit is contained in:
CanbiZ 2025-12-07 21:30:23 +01:00 committed by GitHub
parent d18baa2177
commit ba5bdd94ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
}