Adding a decent error handling

This commit is contained in:
Konstantin 2023-06-02 21:22:57 -04:00 committed by GitHub
parent 728c80d8f6
commit b5e990017f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,14 @@
#!/bin/sh
word=${1:-$(sselp)}
sdcv -n --utf8-output -e "$word" | tail -n +5 | perl -pe 's/<[^>]*>//g' | popup
dict_lookup=$(sdcv -n --utf8-output -e "$word")
if echo "$dict_lookup" | perl -0777 -ne 'exit 0 if /Nothing similar to/ ; exit 1'; then
echo "$dict_lookup" | popup
else
echo "$dict_lookup" | tail -n +5 | perl -pe 's/<[^>]*>//g' | popup
fi