From 09baf73152e3fe61acc781ec0b6264a02ab9cdc8 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 14 Mar 2016 20:59:23 +0000 Subject: [PATCH] Fix various posix shell compliance issues in the rc/ files --- rc/core/man.kak | 4 ++-- rc/extra/clang.kak | 2 +- rc/extra/git-tools.kak | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rc/core/man.kak b/rc/core/man.kak index 27dae843..82de8b1a 100644 --- a/rc/core/man.kak +++ b/rc/core/man.kak @@ -37,7 +37,7 @@ def -hidden -params .. _man %{ %sh{ def -params .. \ -shell-completion %{ - prefix=${1:0:${kak_pos_in_token}} + prefix=$(echo "$1" | cut -c1-${kak_pos_in_token} 2>/dev/null) for page in /usr/share/man/*/${prefix}*.[1-8]*; do candidate=$(basename ${page%%.[1-8]*}) pagenum=$(printf %s "$page" | sed -r 's,^.+/.+\.([1-8][^.]*)\..+$,\1,') @@ -52,7 +52,7 @@ def -params .. \ pagenum="" ## The completion suggestions display the page number, strip them if present - if [[ $subject =~ [a-zA-Z_-]+\([^\)]+\) ]]; then + if expr "$subject" : '[a-zA-Z_-]+\([^\)]+\)'; then pagenum=${subject##*\(} pagenum=${pagenum:0:$((${#pagenum} - 1))} subject=${subject%%\(*} diff --git a/rc/extra/clang.kak b/rc/extra/clang.kak index ce9e09d1..0043cb51 100644 --- a/rc/extra/clang.kak +++ b/rc/extra/clang.kak @@ -37,7 +37,7 @@ def clang-parse -params 0..1 -docstring "Parse the contents of the current buffe *) ft=c++ ;; esac - if [ "$1" == "-complete" ]; then + if [ "$1" = "-complete" ]; then pos=-:${kak_cursor_line}:${kak_cursor_column} header="${kak_cursor_line}.${kak_cursor_column}@${kak_timestamp}" compl=$(clang++ -x ${ft} -fsyntax-only ${kak_opt_clang_options} \ diff --git a/rc/extra/git-tools.kak b/rc/extra/git-tools.kak index 3d77e88b..080530c7 100644 --- a/rc/extra/git-tools.kak +++ b/rc/extra/git-tools.kak @@ -29,7 +29,7 @@ def -params 1.. \ -docstring %sh{printf "%%{Git wrapping helper\navailable commands:\n add\n rm\n blame\n commit\n checkout\n diff\n hide-blame\n log\n show\n show-diff\n status\n update-diff}"} \ -shell-completion %{ shift $(expr ${kak_token_to_complete}) - prefix=${1:0:${kak_pos_in_token}} + prefix=$(echo "${1}" | cut -c1-${kak_pos_in_token} 2>/dev/null) ( for cmd in add rm blame commit checkout diff hide-blame log show show-diff status update-diff; do expr "${cmd}" : "^\(${prefix}.*\)$"