Fixed "service" completion, thanks to John Hedges (Debian: #586210)

The patch makes it safe even when every file in /etc/init.d/*
  has a proper completion (unlikely, but seems like it happened).

  Thanks to John Hedges <john@drystone.co.uk> for the patch, slightly
  modified to make it more compact.
master
David Paleino 2010-06-17 17:43:18 +02:00
parent c858043cbc
commit 1f8b55a92a
2 changed files with 5 additions and 4 deletions

View File

@ -1,7 +1,7 @@
bash-completion (2.x)
[ David Paleino ]
* Start work on 2.0
* Fixed "service" completion, thanks to John Hedges (Debian: #586210)
[ Ville Skyttä ]
* Activate hping2 completion also for hping and hping3.

View File

@ -32,9 +32,10 @@ _service()
return 0
} &&
complete -F _service service
[ -d /etc/init.d/ ] && complete -F _service -o default \
$(for i in /etc/init.d/*; do
complete -p ${i##*/} &>/dev/null || printf '%s\n' ${i##*/}; done)
[ -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;)
# Local variables:
# mode: shell-script