about summary refs log tree commit diff
path: root/Functions
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-06-04 12:07:35 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-06-04 12:07:35 +0000
commit1fbe8436876b81f338bbe9a4aaf601b4c2016e4a (patch)
tree9a825a7a88be310aa0326124643ec6f90d213f5e /Functions
parent023f6ce4e19331c3658c58955e178ca92783c5a1 (diff)
downloadzsh-1fbe8436876b81f338bbe9a4aaf601b4c2016e4a.tar.gz
zsh-1fbe8436876b81f338bbe9a4aaf601b4c2016e4a.tar.xz
zsh-1fbe8436876b81f338bbe9a4aaf601b4c2016e4a.zip
23518: MIME styles find-file-in-path and file-path.
Diffstat (limited to 'Functions')
-rw-r--r--Functions/MIME/zsh-mime-handler19
1 files changed, 17 insertions, 2 deletions
diff --git a/Functions/MIME/zsh-mime-handler b/Functions/MIME/zsh-mime-handler
index 83df242af..9b604c422 100644
--- a/Functions/MIME/zsh-mime-handler
+++ b/Functions/MIME/zsh-mime-handler
@@ -64,6 +64,22 @@ zstyle -a $context handle-nonexistent hand_nonex ||
 local pattern
 local -a files
 
+# Search some path for the file, if required.
+# We do this before any other tests that need to find the
+# actual file or its directory.
+local dir
+local -a filepath
+if zstyle -t $context find-file-in-path && [[ $1 != /* ]] &&
+  [[ $1 != */* || -o pathdirs ]]; then
+  zstyle -a $context file-path filepath || filepath=($path)
+  for dir in $filepath; do
+    if [[ -e $dir/$1 ]]; then
+      1=$dir/$1
+      break
+    fi
+  done
+fi
+
 # In case the pattern contains glob qualifiers, as it does by default,
 # we need to do real globbing, not just pattern matching.
 # The strategy is to glob the files in the directory using the
@@ -111,7 +127,6 @@ zstyle -t $context current-shell && no_sh=yes
 # terminal and display is set.
 zstyle -t $context never-background && no_bg=yes
 
-local -a files
 local hasmeta stdin
 
 # See if the handler has shell metacharacters in.
@@ -120,7 +135,7 @@ if [[ $handler = *[\\\;\*\?\|\"\'\`\$]* ]]; then
     hasmeta=1
 fi
 
-local -a execargs
+local -a execargs files
 
 if [[ $handler = *%s* ]]; then
   # We need to replace %s with the file(s).