From 1214a6fb1aee718035bd7080f8cdbeba545da745 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sat, 5 Aug 2023 18:58:09 -0400 Subject: [PATCH] nuke spaces and also remove tail --- dictpopup | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/dictpopup b/dictpopup index 6edd93e..eb8fbd0 100755 --- a/dictpopup +++ b/dictpopup @@ -1,14 +1,12 @@ #!/bin/sh word=${1:-$(sselp)} +word_without_spaces=$(echo "$word" | tr -d ' ') -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 +dict_lookup=$(sdcv -n --utf8-output -e "$word_without_spaces") +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 - + echo "$dict_lookup" | perl -0777 -pe 's/^.*\n.*\n.*\n.*\n//; s/<[^>]*>//g' | popup fi