Skip to content

Commit 1ac9169

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 6162fd2 commit 1ac9169

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

bash_completion

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,8 +2223,13 @@ _comp_compgen_services()
22232223
local _generated=$({
22242224
systemctl list-units --full --all ||
22252225
systemctl list-unit-files
2226-
} 2>/dev/null |
2227-
_comp_awk '$1 ~ /\.service$/ { sub("\\.service$", "", $1); print $1 }')
2226+
} 2>/dev/null | _comp_awk '
2227+
# Example output from systemctl:
2228+
# httpd.service loaded active running The Apache HTTP Server
2229+
# * iptables.service not-found inactive dead iptables.service
2230+
sub(/\.service$/, "", $1) { print $1; next }
2231+
sub(/\.service$/, "", $2) { print $2 }
2232+
')
22282233
_comp_compgen -a split -l -- "$_generated" && status=0
22292234

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

0 commit comments

Comments
 (0)