From 273455ecc8ba46184cd92815ea6adddd2f6cd1c0 Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Sat, 24 Sep 2016 12:27:35 +0300 Subject: [PATCH] Fix non POSIX instructions, print errors when they occur --- rc/base/spell.kak | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/rc/base/spell.kak b/rc/base/spell.kak index 00bcdae3..9b0fe5c4 100644 --- a/rc/base/spell.kak +++ b/rc/base/spell.kak @@ -23,19 +23,19 @@ def -params ..1 spell -docstring "Check spelling of the current buffer with aspe line_num=1 regions=$kak_timestamp while read line; do - case $line in - \&*) - begin=$(printf %s\\n "$line" | cut -d ' ' -f 4 | sed 's/:$//') - ;& - '#'*) - word=$(printf %s\\n "$line" | cut -d ' ' -f 2) - begin=${begin:-$(printf %s\\n "$line" | cut -d ' ' -f 3)} - end=$((begin + ${#word})) - # printf %s\\n "echo -debug -- line: $line_num, word: $word, begin: $begin, end: $end" - regions="$regions:$line_num.$begin,$line_num.$end|Error" - ;; - '') ((++line_num)) ;; - *) ;; + case "$line" in + \&*|'#'*) + if expr "$line" : '^&' >/dev/null; then + begin=$(printf %s\\n "$line" | cut -d ' ' -f 4 | sed 's/:$//') + else + begin=$(printf %s\\n "$line" | cut -d ' ' -f 3) + fi + word=$(printf %s\\n "$line" | cut -d ' ' -f 2) + end=$((begin + ${#word})) + regions="$regions:$line_num.$begin,$line_num.$end|Error" + ;; + '') line_num=$((line_num + 1));; + *) printf %s\\n "echo -color Error %{$line}";; esac done printf %s\\n "set buffer spell_regions %{$regions}"