diff options
author | Paul Ackersviller <packersv@users.sourceforge.net> | 2007-04-26 04:02:13 +0000 |
---|---|---|
committer | Paul Ackersviller <packersv@users.sourceforge.net> | 2007-04-26 04:02:13 +0000 |
commit | 0fd5156fdff9e8b597f77260fd1ba8f3d1c8c729 (patch) | |
tree | 70ceffe3c295dac73b5b2456a19309c755ca9e19 /Completion | |
parent | eaf13e9eabfc0531d6e3dedc090f0f495c8139d4 (diff) | |
download | zsh-0fd5156fdff9e8b597f77260fd1ba8f3d1c8c729.tar.gz zsh-0fd5156fdff9e8b597f77260fd1ba8f3d1c8c729.tar.xz zsh-0fd5156fdff9e8b597f77260fd1ba8f3d1c8c729.zip |
Merge workers/{22386, 23203} for version detection.
Diffstat (limited to 'Completion')
-rw-r--r-- | Completion/X/Command/_acroread | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/Completion/X/Command/_acroread b/Completion/X/Command/_acroread index afcd3188c..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=${${${(f)"$(<$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=${${${(f)"$(<$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 |