From 4ba7c7a2c4152e603b7c58b2a3def2820c04c77b Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Wed, 1 Mar 2017 16:14:02 +0300 Subject: [PATCH] rc: POSIX and cosmetic fixes in the `spell` script` --- rc/base/spell.kak | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/rc/base/spell.kak b/rc/base/spell.kak index ab81f67b..865c3ec9 100644 --- a/rc/base/spell.kak +++ b/rc/base/spell.kak @@ -16,9 +16,9 @@ Formats of language supported: } %sh{ if [ $# -ge 1 ]; then - if [ ${#1} -ne 2 -a ${#1} -ne 5 ]; then + if [ ${#1} -ne 2 ] && [ ${#1} -ne 5 ]; then echo 'echo -color Error Invalid language code (examples of expected format: en, en_US, en-US)' - rm -r "$(dirname "$kak_opt_spell_tmp_file")" + rm -rf "$(dirname "$kak_opt_spell_tmp_file")" exit 1 else options="-l '$1'" @@ -50,18 +50,18 @@ Formats of language supported: printf 'set "buffer=%s" spell_regions %%{%s}' "${kak_bufname}" "${regions}" \ | kak -p "${kak_session}" } - rm -r $(dirname "$kak_opt_spell_tmp_file") + rm -rf $(dirname "$kak_opt_spell_tmp_file") } /dev/null 2>&1 & } } -def spell-replace %{%sh{ - suggestions=$(echo "$kak_selection" | aspell -a | grep '^&' | cut -d: -f2) - menu=$(echo "${suggestions#?}" | awk -F', ' ' - { - for (i=1; i<=NF; i++) - printf "%s", "%{"$i"}" "%{exec -itersel c"$i"be}" - } +def spell-replace %{ %sh{ + suggestions=$(printf %s "$kak_selection" | aspell -a | grep '^&' | cut -d: -f2) + menu=$(printf %s "${suggestions#?}" | awk -F', ' ' + { + for (i=1; i<=NF; i++) + printf "%s", "%{"$i"}" "%{exec -itersel c"$i"be}" + } ') - printf '%s\n' "try %{ menu -auto-single $menu }" -}} + printf 'try %%{ menu -auto-single %s }' "${menu}" +} }