Skip to content

SysVInit services targets parsing broken #1498

@Berbe

Description

@Berbe

Describe the bug

Since the rewrite of _service() to _comp_complete_service() in 2.12, SysVInit services targets are not being parsed correctly anymore.

This issue only occurs to me now, having upgraded from Devuan Daedalus 5 (deriving from Debian Bookworm 12) to Devuan Excalibur 6 (deriving from Debian Trixie 13).
The bash-completion package is untouched from upstream Debian.

To reproduce

  1. Grab either:
  2. Start a shell
  3. Type sudo service acpid
  4. Press
  5. Wrong output: sudo service acpid start stop restart reload force-reload status start stop
    Image

Expected behavior

  1. Grab either:
  2. Start a shell
  3. Type sudo service acpid
  4. Press
  5. Targets are being listed Image

Versions (please complete the following information)

  • [*] Operating system name/distribution and version:
    • Devuan Excalibur 6
    • Debian Trixie 13
  • [*] bash version, echo "$BASH_VERSION": 5.2.37(1)-release
  • [*] bash-completion version, (IFS=.; echo "${BASH_COMPLETION_VERSINFO[*]}"): 2.16.0

Additional context

A patch for the 2.16.0 version would be nice, so it could be suggested as at update at Debian's

Investigation

I was able to produce a basic hack patch, taking the pre-2.12 working part and overwriting the since-2.12 failing one:

--- /usr/share/bash-completion/bash_completion    2025-11-04 20:38:46.147140782 +0100
+++ /usr/share/bash-completion/bash_completion.fixed     2025-11-04 20:38:59.323846976 +0100
@@ -2093,9 +2093,9 @@
     else
         local sysvdirs
         _comp_sysvdirs || return 1
-        _comp_compgen_split -l -- "$(command sed -e 'y/|/ /' \
-            -ne 's/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p' \
-            "${sysvdirs[0]}/${prev##*/}" 2>/dev/null) start stop"
+        COMPREPLY=($(compgen -W '`command sed -e "y/|/ /" \
+            -ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \
+            ${sysvdirs[0]}/${prev##*/} 2>/dev/null` start stop' -- "$cur"))
     fi
 } &&
     complete -F _comp_complete_service service

With this, services targets autocompletion works again, even though it is unsatisfactory to go back to the old behaviour and not use the refactored function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions