Fix non POSIX instructions, print errors when they occur

This commit is contained in:
Frank LENORMAND 2016-09-24 12:27:35 +03:00
parent 4f874a3679
commit 273455ecc8

View File

@ -23,19 +23,19 @@ def -params ..1 spell -docstring "Check spelling of the current buffer with aspe
line_num=1 line_num=1
regions=$kak_timestamp regions=$kak_timestamp
while read line; do while read line; do
case $line in case "$line" in
\&*) \&*|'#'*)
begin=$(printf %s\\n "$line" | cut -d ' ' -f 4 | sed 's/:$//') if expr "$line" : '^&' >/dev/null; then
;& begin=$(printf %s\\n "$line" | cut -d ' ' -f 4 | sed 's/:$//')
'#'*) else
word=$(printf %s\\n "$line" | cut -d ' ' -f 2) begin=$(printf %s\\n "$line" | cut -d ' ' -f 3)
begin=${begin:-$(printf %s\\n "$line" | cut -d ' ' -f 3)} fi
end=$((begin + ${#word})) word=$(printf %s\\n "$line" | cut -d ' ' -f 2)
# printf %s\\n "echo -debug -- line: $line_num, word: $word, begin: $begin, end: $end" end=$((begin + ${#word}))
regions="$regions:$line_num.$begin,$line_num.$end|Error" regions="$regions:$line_num.$begin,$line_num.$end|Error"
;; ;;
'') ((++line_num)) ;; '') line_num=$((line_num + 1));;
*) ;; *) printf %s\\n "echo -color Error %{$line}";;
esac esac
done done
printf %s\\n "set buffer spell_regions %{$regions}" printf %s\\n "set buffer spell_regions %{$regions}"