cpp.kak: fix alt_dirs handling with more than 2 directories

This commit is contained in:
Maxime Coste 2013-03-28 14:28:15 +01:00
parent 96b017f76e
commit 08873a779a

View File

@ -38,7 +38,7 @@ decl str-list alt_dirs ".,.."
def alt %{ %sh{ def alt %{ %sh{
shopt -s extglob shopt -s extglob
alt_dirs=${kak_opt_alt_dirs/,/ } alt_dirs=${kak_opt_alt_dirs//,/ }
file=$(basename ${kak_bufname}) file=$(basename ${kak_bufname})
dir=$(dirname ${kak_bufname}) dir=$(dirname ${kak_bufname})
@ -46,13 +46,13 @@ def alt %{ %sh{
*.c|*.cc|*.cpp|*.cxx|*.C) *.c|*.cc|*.cpp|*.cxx|*.C)
for alt_dir in ${alt_dirs}; do for alt_dir in ${alt_dirs}; do
altname=$(ls -1 "${dir}/${alt_dir}/${file%.*}".@(h|hh|hpp|hxx|H) 2> /dev/null | head -n 1) altname=$(ls -1 "${dir}/${alt_dir}/${file%.*}".@(h|hh|hpp|hxx|H) 2> /dev/null | head -n 1)
[[ -n ${altname} ]] && break [[ -e ${altname} ]] && break
done done
;; ;;
*.h|*.hh|*.hpp|*.hxx|*.H) *.h|*.hh|*.hpp|*.hxx|*.H)
for alt_dir in ${alt_dirs}; do for alt_dir in ${alt_dirs}; do
altname=$(ls -1 "${dir}/${alt_dir}/${file%.*}".@(c|cc|cpp|cxx|C) 2> /dev/null | head -n 1) altname=$(ls -1 "${dir}/${alt_dir}/${file%.*}".@(c|cc|cpp|cxx|C) 2> /dev/null | head -n 1)
[[ -n ${altname} ]] && break [[ -e ${altname} ]] && break
done done
;; ;;
esac esac