Add error handling
Rewrite line by line to make escaping easier
This commit is contained in:
parent
246735520f
commit
063a702bf4
|
@ -151,7 +151,7 @@ define-command \
|
|||
|
||||
define-command -params 0.. \
|
||||
-docstring "Add the current selection to the dictionary" \
|
||||
spell-add %{ nop %sh{
|
||||
spell-add %{ evaluate-commands %sh{
|
||||
if [ -n "$kak_opt_spell_last_lang" ]; then
|
||||
options="-l '$kak_opt_spell_last_lang'"
|
||||
fi
|
||||
|
@ -159,10 +159,12 @@ define-command -params 0.. \
|
|||
# use selections
|
||||
eval set -- "$kak_quoted_selections"
|
||||
fi
|
||||
words=""
|
||||
while [ $# -gt 0 ]; do
|
||||
words="$words"$(printf '*%s\\n#\\n' "$1")
|
||||
word="$1"
|
||||
if ! printf '*%s\n#\n' "${word}" | eval "aspell -a $options" >/dev/null; then
|
||||
printf 'fail "Unable to add word: %s"' "$(printf %s "${word}" | sed 's/"/&&/g')"
|
||||
exit 1
|
||||
fi
|
||||
shift
|
||||
done
|
||||
printf %b\\n "$words" | eval "aspell -a $options"
|
||||
}}
|
||||
|
|
Loading…
Reference in New Issue
Block a user