about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2009-10-04 18:20:00 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2009-10-04 18:20:00 +0000
commit8ed0fad414daa81c7f7232139e3022b46106437f (patch)
tree03b5ebfd02d0271bf97a671ae9a20abb6f311522 /Completion
parent179cd828a57c36f312ed7f95abf5e7d8d5fe44a2 (diff)
downloadzsh-8ed0fad414daa81c7f7232139e3022b46106437f.tar.gz
zsh-8ed0fad414daa81c7f7232139e3022b46106437f.tar.xz
zsh-8ed0fad414daa81c7f7232139e3022b46106437f.zip
27308, based on 27305 from Edgar Merino:
search for init scripts in other locations
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Unix/Command/_init_d15
-rw-r--r--Completion/Unix/Type/_services14
2 files changed, 27 insertions, 2 deletions
diff --git a/Completion/Unix/Command/_init_d b/Completion/Unix/Command/_init_d
index 9a5ed9ae7..72d11023f 100644
--- a/Completion/Unix/Command/_init_d
+++ b/Completion/Unix/Command/_init_d
@@ -7,7 +7,20 @@ _compskip=all
 # This should probably be system specific...
 
 script=$words[1]
-[[ $script = */* ]] || script=/etc/init.d/$script
+if [[ $script != */* ]]; then
+  local -a scriptpath
+  local dir
+  # Known locations of init scripts
+  # C.f. Unix/Type/_services
+  scriptpath=(/etc/init.d /etc/rc.d /etc/rc.d/init.d)
+
+  for dir in $scriptpath; do
+    if [[ -f $dir/$script ]]; then
+      script=$dir/$script
+      break
+    fi
+  done
+fi
 
 # If the file starts with `#!' we hope that this is a shell script
 # and get lines looking like <space>foo|bar) with the words in $what.
diff --git a/Completion/Unix/Type/_services b/Completion/Unix/Type/_services
index 2965e0f3e..40136e3c1 100644
--- a/Completion/Unix/Type/_services
+++ b/Completion/Unix/Type/_services
@@ -12,7 +12,19 @@ if chkconfig --list > /dev/null 2>&1; then
     'init:init service:compadd -a inits' \
     'xinetd:xinetd service:compadd -a xinetds' && ret=0
 else
-  _wanted services expl service compadd "$@" - /etc/init.d/*(-*:t) && ret=0
+  local -a scriptpath
+  local dir
+  # Known locations of init scripts
+  # C.f. Unix/Commands/_init_d
+  scriptpath=(/etc/init.d /etc/rc.d /etc/rc.d/init.d)
+
+  for dir in $scriptpath; do
+    if [[ -d $dir ]]; then
+      break
+    fi
+  done
+  _wanted services expl service compadd "$@" - $dir/*(-*:t) &&
+  ret=0
 fi
 
 return ret