From 457e07c6f5ccc6cd2c32ca2b58371c81dc863d0b Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani <3fb650a9-b47e-4604-a282-1dd91953b2ee@anonaddy.me> Date: Sun, 18 Oct 2020 08:54:15 -0400 Subject: [PATCH] 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 --- charsel | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) 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 -- 2.39.2