about summary refs log tree commit diff
path: root/Completion/compaudit
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2016-11-06 00:00:38 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2016-11-06 00:00:38 -0700
commitc282abc6bd9bbc6dc204d217d8e94ea4565e68ca (patch)
tree1d77db708f8a6e3cf0c13ccd7fcec2d57aac7fda /Completion/compaudit
parentdee0bce7b4137949cb80ccc21339ea128c7bc5d8 (diff)
downloadzsh-c282abc6bd9bbc6dc204d217d8e94ea4565e68ca.tar.gz
zsh-c282abc6bd9bbc6dc204d217d8e94ea4565e68ca.tar.xz
zsh-c282abc6bd9bbc6dc204d217d8e94ea4565e68ca.zip
Thomas Bereknyei, Mic92: 39831: find "getent" by the usual command search, not just /usr/bin/
Also tweak the replacement getent to handle /etc/hosts format.
Diffstat (limited to 'Completion/compaudit')
-rw-r--r--Completion/compaudit6
1 files changed, 4 insertions, 2 deletions
diff --git a/Completion/compaudit b/Completion/compaudit
index fb0463ca5..93a043124 100644
--- a/Completion/compaudit
+++ b/Completion/compaudit
@@ -15,8 +15,10 @@ compaudit() {                           # Define and then call
 emulate -L zsh
 setopt extendedglob
 
-[[ -x /usr/bin/getent ]] || getent() {
-  if [[ $2 = <-> ]]; then
+[[ -n $commands[getent] ]] || getent() {
+  if [[ $1 = hosts ]]; then
+    sed 's/#.*//' /etc/$1 | grep -w $2
+  elif [[ $2 = <-> ]]; then
     grep ":$2:[^:]*$" /etc/$1
   else
     grep "^$2:" /etc/$1