Skip to content

Commit 809b7db

Browse files
committed
fix(_comp_compgen_services): skip service status marks
Recent versions of systemctl seems to prefix a character representing the status before the unit names. Thus, in addition to $1, $2 may also contain a service name.
1 parent 2cb4b13 commit 809b7db

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

bash_completion

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,8 +2208,13 @@ _comp_compgen_services()
22082208
local _generated=$({
22092209
systemctl list-units --full --all ||
22102210
systemctl list-unit-files
2211-
} 2>/dev/null |
2212-
_comp_awk '$1 ~ /\.service$/ { sub("\\.service$", "", $1); print $1 }')
2211+
} 2>/dev/null | _comp_awk '
2212+
# Example output from systemctl:
2213+
# httpd.service loaded active running The Apache HTTP Server
2214+
# * iptables.service not-found inactive dead iptables.service
2215+
sub(/\.service$/, "", $1) { print $1; next }
2216+
sub(/\.service$/, "", $2) { print $2 }
2217+
')
22132218
_comp_compgen -a split -l -- "$_generated" && status=0
22142219

22152220
if [[ -x /sbin/upstart-udev-bridge ]]; then

0 commit comments

Comments
 (0)