summaryrefslogtreecommitdiff
path: root/rc/cpp.kak
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2014-03-06 03:35:38 +0000
committerMaxime Coste <frrrwww@gmail.com>2014-03-06 03:35:38 +0000
commitf733007a7ba8b35091ebca882cbf523fc5234e71 (patch)
tree2b0c2d41c101d169cc88973128ea0e08d3e8e0a1 /rc/cpp.kak
parent8e0b5d67aa2e6dff9128c3f9664dc6447822317d (diff)
Port most kak scripts to be POSIX shell compliant
Diffstat (limited to 'rc/cpp.kak')
-rw-r--r--rc/cpp.kak20
1 files changed, 13 insertions, 7 deletions
diff --git a/rc/cpp.kak b/rc/cpp.kak
index 1edb9b6c..4a154576 100644
--- a/rc/cpp.kak
+++ b/rc/cpp.kak
@@ -75,26 +75,32 @@ hook global BufNew .*\.(h|hh|hpp|hxx|H) _cpp_insert_include_guards
decl str-list alt_dirs ".;.."
def alt -docstring "Jump to the alternate file (header/implementation)" %{ %sh{
- shopt -s extglob
- alt_dirs=${kak_opt_alt_dirs//;/ }
+ alt_dirs=$(echo ${kak_opt_alt_dirs} | sed -e 's/;/ /g')
file=$(basename ${kak_buffile})
dir=$(dirname ${kak_buffile})
case ${file} in
*.c|*.cc|*.cpp|*.cxx|*.C)
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)
- [[ -e ${altname} ]] && break
+ for ext in h hh hpp hxx H; do
+ altname="${dir}/${alt_dir}/${file%.*}.${ext}"
+ [ -f ${altname} ] && break
+ done
+ [ -f ${altname} ] && break
done
;;
*.h|*.hh|*.hpp|*.hxx|*.H)
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)
- [[ -e ${altname} ]] && break
+ for ext in c cc cpp cxx C; do
+ altname="${dir}/${alt_dir}/${file%.*}.${ext}"
+ [ -f ${altname} ] && break
+ done
+ [ -f ${altname} ] && break
done
;;
esac
- if [[ -e ${altname} ]]; then
+ echo debug ${altname}
+ if [ -f ${altname} ]; then
echo edit "'${altname}'"
else
echo echo "'alternative file not found'"