From: Armaan Bhojwani <3fb650a9-b47e-4604-a282-1dd91953b2ee@anonaddy.me> Date: Sun, 18 Oct 2020 12:54:15 +0000 (-0400) Subject: fixed small bug, rearranged internals X-Git-Url: https://git.armaanb.net/?p=charsel.git;a=commitdiff_plain;h=457e07c6f5ccc6cd2c32ca2b58371c81dc863d0b;hp=8144e0931937918fff0f19a432741d849342ebf2 fixed small bug, rearranged internals Fixed a small bug where spaces would break grep, also made the system by which inputs are checked more streamlined --- diff --git a/charsel b/charsel index 6c6fc91..b15a1ff 100755 --- a/charsel +++ b/charsel @@ -19,7 +19,7 @@ ######################################################################## -VERSION=2.0.0 +VERSION=2.0.1 # Define argument functions function usage() { @@ -171,27 +171,30 @@ do # User input read -p "| input shortcode: " -N $LENGTH INPUT - # This can definately be simplifed, but it works fine - # Finds line number of shortcode - LINENUMBER=$(cut -f 1 -d ',' -s $CHARFILE | grep -wn $INPUT | cut -d : -f 1) - - # Outputs character selected above - OUTPUT=$(cut -f 2 -d ',' -s $CHARFILE | head -$LINENUMBER | tail +$LINENUMBER) - - # Check to see if the shortcode actually exists - if [[ $(cut -f 1 -d ',' -s $CHARFILE | grep -wnc $INPUT) == "0" ]] - then - OUTPUT="" - fi - - if [[ $INPUT == ";"* ]] + if [[ $INPUT == ";"* ]] # Semicolon exits then clear exit 0 - fi + elif [[ $INPUT == " "* ]] # Spaces dont count + then + OUTPUT="" + clear + else + # Finds line number of shortcode + LINENUMBER=$(cut -f 1 -d ',' -s $CHARFILE | grep -wn $INPUT | cut -d : -f 1) + + # Outputs character selected above + OUTPUT=$(cut -f 2 -d ',' -s $CHARFILE | head -$LINENUMBER | tail +$LINENUMBER) - # Copy output to clipboard - echo $OUTPUT | xclip -selection clipboard + # Check to see if the shortcode actually exists + if [[ $(cut -f 1 -d ',' -s $CHARFILE | grep -wnc $INPUT) == "0" ]] + then + OUTPUT="" + fi - clear + # Copy output to clipboard + echo $OUTPUT | xclip -selection clipboard + + clear + fi done