File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed
Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -72,17 +72,17 @@ stop_all_services() {
7272 local service_patterns=(" $@ " )
7373
7474 for pattern in " ${service_patterns[@]} " ; do
75- # Find all matching services
75+ # Find all matching services (grep || true to handle no matches)
76+ local services
77+ services=$( systemctl list-units --type=service --all 2> /dev/null |
78+ grep -oE " ${pattern} [^ ]*\.service" 2> /dev/null | sort -u) || true
7679
77- systemctl list-units --type=service --all 2> /dev/null |
78- grep -oE " ${pattern} [^ ]*\.service" |
79- sort -u |
80+ if [[ -n " $services " ]]; then
8081 while read -r service; do
81-
8282 $STD systemctl stop " $service " 2> /dev/null || true
8383 $STD systemctl disable " $service " 2> /dev/null || true
84- done
85-
84+ done <<< " $services "
85+ fi
8686 done
8787
8888}
You can’t perform that action at this time.
0 commit comments