From: Armaan Bhojwani <3fb650a9-b47e-4604-a282-1dd91953b2ee@anonaddy.me> Date: Fri, 16 Oct 2020 23:32:46 +0000 (-0400) Subject: check for existence of shortcut X-Git-Url: https://git.armaanb.net/?p=charsel.git;a=commitdiff_plain;h=17f712c5288936886131e5d9c11e962c745fe7df check for existence of shortcut added an if statement to check whether the inputed short code actually exists --- diff --git a/charsel b/charsel index a8b5e66..adffd27 100755 --- a/charsel +++ b/charsel @@ -75,10 +75,17 @@ do LINENUMBER=$(cut -f 1 -d ',' -s $CHARFILE \ | grep -wn $INPUT \ | cut -d : -f 1) + OUTPUT=$(cut -f 2 -d ',' -s $CHARFILE \ | head -$LINENUMBER \ | tail +$LINENUMBER) + if [[ $(cut -f 1 -d ',' -s $CHARFILE \ + | grep -wnc $INPUT) == "0" ]] + then + OUTPUT="" + fi + # Copy output to clipboard echo $OUTPUT | xclip -selection clipboard