From 1fbe8436876b81f338bbe9a4aaf601b4c2016e4a Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 4 Jun 2007 12:07:35 +0000 Subject: 23518: MIME styles find-file-in-path and file-path. --- Functions/MIME/zsh-mime-handler | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'Functions') 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). -- cgit 1.4.1