about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-03-01 19:22:31 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-03-01 19:22:31 +0000
commit41d485cb75897efb6d2b4febfe346177aa4533f8 (patch)
tree402ac3e6b8388a1c22b1c90b349c6d388ba3002b
parentc8d1071cd8ca5c92e7d75b5dda2be529da6755bd (diff)
downloadzsh-41d485cb75897efb6d2b4febfe346177aa4533f8.tar.gz
zsh-41d485cb75897efb6d2b4febfe346177aa4533f8.tar.xz
zsh-41d485cb75897efb6d2b4febfe346177aa4533f8.zip
23203: acroread -version to get version (from Zvi)
Fix previous methods as fallback
-rw-r--r--ChangeLog6
-rw-r--r--Completion/X/Command/_acroread28
2 files changed, 27 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 5d1ff2ef1..c6a106681 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-03-01  Peter Stephenson  <pws@csr.com>
+
+	* 23203: Completion/X/Command/_acroread: use -version
+	to get version (spotted by Zvi) and fix the other methods
+	as fallback.
+
 2007-02-27  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* unposted: Doc/Zsh/compsys.yo: document now useful -t
diff --git a/Completion/X/Command/_acroread b/Completion/X/Command/_acroread
index c2832d513..51d64a475 100644
--- a/Completion/X/Command/_acroread
+++ b/Completion/X/Command/_acroread
@@ -1,15 +1,29 @@
 #compdef acroread
 
 local curcontext="$curcontext" state line
+local cmdfile
 
-# Try extracting the version number directly from the executable.
-# (This will fail if the executable is a wrapper script for acroread.)
-local ver=${${${(Mf)"$(<$commands[$words[1]])"}:#ver=*}##ver=}
-[[ -n $ver ]] && _acroread_version=$ver
+if [[ -z $_acroread_version ]]; then
+  _acroread_version="$($words[1] -version 2>/dev/null)"
+fi
+
+if [[ -z $_acroread_version ]]; then
+  if [[ $words[1] = */* && -x $words[1] ]]; then
+    cmdfile=$words[1]
+  elif [[ -x $commands[$words[1]] ]]; then
+    cmdfile=$commands[$words[1]]
+  fi
+
+  # Try extracting the version number directly from the executable.
+  # (This will fail if the executable is a wrapper script for acroread.)
+  _acroread_version=${${(M)${(f)"$(<$cmdfile)"}:#ver=*}##ver=}
 
-if (( ! $+_acroread_version )); then
-  local acropath=${${(s. .)${${(f)"$($words[1] -help 2>&1)"}[1]}}[2]}
-  _acroread_version=${${${(Mf)"$(<$acropath)"}:#ver=*}##ver=}
+  if [[ -z $_acroread_version ]]; then
+    local acropath=${${(s. .)${${(f)"$($words[1] -help 2>&1)"}[1]}}[2]}
+    if [[ -r $acropath ]]; then
+      _acroread_version=${${(M)${(f)"$(<$acropath)"}:#ver=*}##ver=}
+    fi
+  fi
 fi
 
 if [[ $_acroread_version == 7.* ]]; then