On Sat 10-09-2005, Jan Christoph Ebersbach wrote:
> On Fri 09-09-2005, Justin Pryzby wrote:
>
> > I agree! And it should work with sudo, too. Your patch doesn't
> > implement /etc/init.d/$foo start,stop completion, correct?
>
> The start,stop completion should work with my patch.
>
> If the previous word is not invoke-rc.d, start, stop ... will be
> completed.
>
> + *) COMPREPLY=( $( compgen -W 'start stop restart reload
> + force-reload' -- $cur ) ) return 0 ;;
>
Ah, there is a bug - the find-parameter "-perm +u=x" should be "-perm
+111"
Here is the correct patch.
--- bash_completion.old 2005-09-10 00:44:54.000000000 +0200
+++ bash_completion 2005-09-10 10:58:44.000000000 +0200
@@ -3238,6 +3238,32 @@
} &&
complete -F _mysqladmin mysqladmin
+# invoke-rc.d(8) completion
+#
+have invoke-rc.d &&
+_invokercd()
+{
+ local cur prev options
+
+ COMPREPLY=()
+ cur=${COMP_WORDS[COMP_CWORD]}
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ case $prev in
+ invoke-rc.d)
+ files=$( find /etc/init.d/ -perm +111 | sed 's|^/etc/init.d/||' )
+ COMPREPLY=( $( compgen -W "${files}" -- $cur ) )
+ return 0
+ ;;
+
+ *)
+ COMPREPLY=( $( compgen -W 'start stop restart reload force-reload' --
$cur ) )
+ return 0
+ ;;
+ esac
+} &&
+complete -F _invokercd invoke-rc.d
+
# gzip(1) completion
#
have gzip &&