On Sat, 05 Nov 2011 20:19:02 +0200 Ville Skyttä <ville.sky...@iki.fi> wrote:
> On 11/05/2011 06:48 PM, Igor Murzov wrote: > > The following commit has been merged in the master branch: > > commit 9717124ab7bad30b6d8ba02ef91850c6bb74dd63 > > Author: Igor Murzov <e-m...@date.by> > > Date: Sat Nov 5 20:13:05 2011 +0300 > > > > service, _services: Make these work on Slackware GNU/Linux. > > The two changes below cause a regression: for example on Fedora/Red Hat > boxes, there's both /etc/init.d and /etc/rc.d/init.d (both pointing to > the same place), and as a consequence of this patch, we now get > completions only for the /etc/rc.d/init.d ones and not the /etc/init.d > ones. The /etc/rc.d/init.d ones are more rarely typed by people if I > guess correctly, but both should continue to work as they did before. > > > @@ -1843,7 +1857,7 @@ _completion_loader() > > [[ $BASH_SOURCE == */* ]] && compdir="${BASH_SOURCE%/*}/completions" > > > > # Special case for init.d scripts. > > - if [[ $1 == /etc?(/rc.d)/init.d/* ]]; then > > + if [[ "$1" == $( _sysvdir )/* ]]; then > > . "$compdir/service" &>/dev/null && return 124 || return 1 > > fi > > @@ -26,7 +24,7 @@ _service() > > return 0 > > } && > > complete -F _service service > > -for svc in /etc/init.d/!($_backup_glob) /etc/rc.d/init.d/!($_backup_glob); > > do > > +for svc in $( _sysvdir )/!($_backup_glob); do > > [ -x "$svc" ] && complete -F _service $svc > > done > > unset svc How about this (diff is against prior version as this is more demonstrative)? diff --git a/bash_completion b/bash_completion index 1ef7030..03c9495 100644 --- a/bash_completion +++ b/bash_completion @@ -1843,7 +1843,7 @@ _completion_loader() [[ $BASH_SOURCE == */* ]] && compdir="${BASH_SOURCE%/*}/completions" # Special case for init.d scripts. - if [[ $1 == /etc?(/rc.d)/init.d/* ]]; then + if [[ "$1" == /etc/@(rc.d|init.d)/* ]]; then . "$compdir/service" &>/dev/null && return 124 || return 1 fi diff --git a/completions/service b/completions/service index f008770..e4177f3 100644 --- a/completions/service +++ b/completions/service @@ -15,18 +15,15 @@ _service() if [[ $cword -eq 1 && $prev == ?(*/)service ]]; then _services else - local sysvdir - [ -d /etc/rc.d/init.d ] && \ - sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d COMPREPLY=( $( compgen -W '`sed -e "y/|/ /" \ -ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \ - $sysvdir/${prev##*/} 2>/dev/null` start stop' -- "$cur" ) ) + $prev 2>/dev/null` start stop' -- "$cur" ) ) fi return 0 } && complete -F _service service -for svc in /etc/init.d/!($_backup_glob) /etc/rc.d/init.d/!($_backup_glob); do +for svc in /etc/?(rc.d/)@(init.d|rc.d)/!($_backup_glob) \ [ -x "$svc" ] && complete -F _service $svc done unset svc -- Igor _______________________________________________ Bash-completion-devel mailing list Bash-completion-devel@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/bash-completion-devel