From 603c25903d68c5bb206412af0b43a588ec7c3e14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Mon, 28 Jun 2010 19:54:16 +0300 Subject: [PATCH] Simplify/improve /etc/init.d/* completions. Avoid subshell, do the right thing for filenames with spaces, do not install completions for non-executable files. --- CHANGES | 1 + contrib/service | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 4e9595f2..ab436c2a 100644 --- a/CHANGES +++ b/CHANGES @@ -8,6 +8,7 @@ bash-completion (2.x) * Add crontab and lrzip completions. * Add gif to mplayer filename completions (Alioth: #312512). * Add "short" tarball extensions to unxz, unlzma etc completions. + * Improve /etc/init.d/* completions. -- David Paleino Wed, 16 Jun 2010 17:53:22 +0200 diff --git a/contrib/service b/contrib/service index f27222a1..6efd7c1a 100644 --- a/contrib/service +++ b/contrib/service @@ -32,10 +32,11 @@ _service() return 0 } && complete -F _service service -[ -d /etc/init.d/ ] && ( - services=$(for i in /etc/init.d/*; do - complete -p ${i##*/} &>/dev/null || printf '%s\n' ${i##*/}; done) - [ -n "$services" ] && complete -F _service -o default $services;) +for svc in /etc/init.d/*; do + [ ! -x "$svc" ] || complete -p "${svc##*/}" &>/dev/null || \ + complete -F _service -o default "${svc##*/}" +done +unset svc # Local variables: # mode: shell-script